diff --git a/src/components/graph/costIndicatorChart/index.tsx b/src/components/graph/costIndicatorChart/index.tsx index f3a800e..b850fe5 100644 --- a/src/components/graph/costIndicatorChart/index.tsx +++ b/src/components/graph/costIndicatorChart/index.tsx @@ -33,9 +33,10 @@ interface ChartInterface { single?: any label: any, miniature?: boolean | undefined + years?: string[] } -export default function CostIndicatorChart({ title, data1, data2, label, subtitle, miniature }: ChartInterface) { +export default function CostIndicatorChart({ title, data1, data2, label, subtitle, miniature, years }: ChartInterface) { const labels = label; @@ -47,7 +48,7 @@ export default function CostIndicatorChart({ title, data1, data2, label, subtitl labels, datasets: [ { - label: new Date().getFullYear() - 1, + label: years[0], data: data1?.map(value => value), skipNull: data2?.map(value => value)?.includes(null), borderRadius: 8, @@ -65,7 +66,7 @@ export default function CostIndicatorChart({ title, data1, data2, label, subtitl }, }, { - label: new Date().getFullYear(), + label: years[1], data: data2?.map(value => value), skipNull: data1?.map(value => value)?.includes(null), borderRadius: 8, diff --git a/src/pages/dashboard/index.tsx b/src/pages/dashboard/index.tsx index 897c925..5efaae9 100644 --- a/src/pages/dashboard/index.tsx +++ b/src/pages/dashboard/index.tsx @@ -140,6 +140,7 @@ export default function Dashboard({ grossAnualGraph, grossAnualYears, grossMensa value?.mes.slice(0, 4).includes(costIndicator[0].mes.slice(0, 4))).map(value => value?.custo_unit && !!parseInt(value?.custo_unit) ? value.custo_unit : null)} data2={costIndicator?.filter((value, index) => value?.mes.slice(0, 4).includes(costIndicator[costIndicator.length - 1].mes.slice(0, 4))).map(value => value?.custo_unit && !!parseInt(value?.custo_unit) ? value.custo_unit : null)} + years={[costIndicator[0].mes.slice(0, 4), costIndicator[costIndicator.length - 1].mes.slice(0, 4)]} label={months} miniature />