Skip to content

Commit

Permalink
Filtre les données GES des collectivités sur la source CITEPA
Browse files Browse the repository at this point in the history
  • Loading branch information
mariheck committed Oct 2, 2024
1 parent 926d04f commit 07d72b4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ const IndicateurGazEffetSerre = ({
}: IndicateurGazEffetSerreProps) => {
if (!defaultData || !data || data.length === 0) return null;

// Récupère les données de l'année la plus récente associées à la source CITEPA
const lastYear = Math.max(...data.map((d) => getYear(d.date_valeur)));

const lastYearData = data.filter(
(d) =>
getYear(d.date_valeur) === lastYear &&
secteurIdToLabel[d.identifiant] !== 'Total'
secteurIdToLabel[d.identifiant] !== 'Total' &&
d.source === 'CITEPA'
);

// Récupère le total associé à cette année et à la source CITEPA
const lastYearTotal = data.find(
(d) =>
getYear(d.date_valeur) === lastYear &&
secteurIdToLabel[d.identifiant] === 'Total'
secteurIdToLabel[d.identifiant] === 'Total' &&
d.source === 'CITEPA'
);

if (lastYearData.length <= 1 && !lastYearTotal) return null;
Expand Down
6 changes: 4 additions & 2 deletions packages/site/components/charts/DonutChartWithLegend.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defaultColors } from './chartsTheme';
import { defaultVarColors } from './chartsTheme';
import DonutChart from './DonutChart';

type DonutChartWithLegendProps = {
Expand All @@ -25,7 +25,9 @@ const DonutChartWithLegend = ({
.filter((d) => d.value !== 0)
.map((d, index) => ({
...d,
color: d.color ? d.color : defaultColors[index % defaultColors.length],
color: d.color
? d.color
: defaultVarColors[index % defaultVarColors.length],
}));

return (
Expand Down
19 changes: 18 additions & 1 deletion packages/site/components/charts/chartsTheme.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Theme} from '@nivo/core';
import { Theme } from '@nivo/core';

export const theme: Theme = {
fontFamily: '"Marianne", arial, sans-serif',
Expand Down Expand Up @@ -51,3 +51,20 @@ export const statsColors = [
'#FFB7AE',
'#34BAB5',
];

export const defaultVarColors = [
'#FEF1D8',
'#F7B1C2',
'#A4E7C7',
'#D8EEFE',
'#B8D6F7',
'#FFD0BB',
'#FBE7B5',
'#E4CDEE',
'#C6C3E3',
'#F0DFD8',
'#ECF2BA',
'#ACD9D9',
'#CB94B9',
'#D9D9D9',
];

0 comments on commit 07d72b4

Please sign in to comment.