From c1fc1beab96d5dbc8def590083248cc8e450baec Mon Sep 17 00:00:00 2001 From: Marine Heckler Date: Tue, 1 Oct 2024 17:05:38 +0200 Subject: [PATCH] =?UTF-8?q?Filtre=20les=20donn=C3=A9es=20GES=20des=20colle?= =?UTF-8?q?ctivit=C3=A9s=20sur=20la=20source=20CITEPA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../[code]/[name]/IndicateurGazEffetSerre.tsx | 8 ++++++-- .../charts/DonutChartWithLegend.tsx | 6 ++++-- .../site/components/charts/chartsTheme.tsx | 19 ++++++++++++++++++- 3 files changed, 28 insertions(+), 5 deletions(-) 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', +];