From 0427e572a60cebc50422368a4e4bea8d9cff5ab2 Mon Sep 17 00:00:00 2001 From: Luiz Filipe Date: Tue, 16 Aug 2022 02:52:39 -0300 Subject: [PATCH] unique labels --- .../graph/grossAnualChart/GrossAnualChart.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/graph/grossAnualChart/GrossAnualChart.tsx b/src/components/graph/grossAnualChart/GrossAnualChart.tsx index cc56f49..b248f2b 100644 --- a/src/components/graph/grossAnualChart/GrossAnualChart.tsx +++ b/src/components/graph/grossAnualChart/GrossAnualChart.tsx @@ -102,7 +102,9 @@ export function GrossAnualChart({ title, subtitle, dataProps, label, dataset, ba }, }; - const labels: string[] = label; + const labels: string[] = label.filter(function(item, pos) { + return label.indexOf(item) == pos; + }); //if (bruta) { // labels = [`Até ${new Date().getFullYear()-1}`, `${new Date().getFullYear()}`] //} else { @@ -126,10 +128,12 @@ export function GrossAnualChart({ title, subtitle, dataProps, label, dataset, ba type: 'bar', stacked: true, label: 'Estimado', - data: dataProps.filter(value => value.dad_estimado === true).map((value, index) => { + data: [0].concat(dataProps.filter(value => value.dad_estimado === true).map((value, index) => { if (value.dad_estimado) - return parseFloat(value.economia_acumulada) - }), + return parseFloat(value.economia_acumulada) + else + return 0 + })), borderRadius: 10, backgroundColor: draw('diagonal-right-left', '#C2d5fb'), },