diff --git a/packages/site/app/collectivites/[code]/[name]/IndicateurGazEffetSerre.tsx b/packages/site/app/collectivites/[code]/[name]/IndicateurGazEffetSerre.tsx index a482f76b69..cc27f43526 100644 --- a/packages/site/app/collectivites/[code]/[name]/IndicateurGazEffetSerre.tsx +++ b/packages/site/app/collectivites/[code]/[name]/IndicateurGazEffetSerre.tsx @@ -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; diff --git a/packages/site/components/charts/DonutChartWithLegend.tsx b/packages/site/components/charts/DonutChartWithLegend.tsx index ea8f9c8d9d..44fe07a5a4 100644 --- a/packages/site/components/charts/DonutChartWithLegend.tsx +++ b/packages/site/components/charts/DonutChartWithLegend.tsx @@ -1,4 +1,4 @@ -import { defaultColors } from './chartsTheme'; +import { defaultVarColors } from './chartsTheme'; import DonutChart from './DonutChart'; type DonutChartWithLegendProps = { @@ -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 ( diff --git a/packages/site/components/charts/chartsTheme.tsx b/packages/site/components/charts/chartsTheme.tsx index e3d4dbcf99..50cd31bc55 100644 --- a/packages/site/components/charts/chartsTheme.tsx +++ b/packages/site/components/charts/chartsTheme.tsx @@ -1,4 +1,4 @@ -import {Theme} from '@nivo/core'; +import { Theme } from '@nivo/core'; export const theme: Theme = { fontFamily: '"Marianne", arial, sans-serif', @@ -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', +];