feat: coast indicator chart

This commit is contained in:
joseCorte-exe 2023-04-14 13:33:36 -03:00
parent 682181d130
commit bd306e856d
2 changed files with 5 additions and 3 deletions

View File

@ -33,9 +33,10 @@ interface ChartInterface {
single?: any single?: any
label: any, label: any,
miniature?: boolean | undefined 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; const labels = label;
@ -47,7 +48,7 @@ export default function CostIndicatorChart({ title, data1, data2, label, subtitl
labels, labels,
datasets: [ datasets: [
{ {
label: new Date().getFullYear() - 1, label: years[0],
data: data1?.map(value => value), data: data1?.map(value => value),
skipNull: data2?.map(value => value)?.includes(null), skipNull: data2?.map(value => value)?.includes(null),
borderRadius: 8, 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), data: data2?.map(value => value),
skipNull: data1?.map(value => value)?.includes(null), skipNull: data1?.map(value => value)?.includes(null),
borderRadius: 8, borderRadius: 8,

View File

@ -140,6 +140,7 @@ export default function Dashboard({ grossAnualGraph, grossAnualYears, grossMensa
<CostIndicatorChart title='' subtitle='' <CostIndicatorChart title='' subtitle=''
data1={costIndicator?.filter((value, index) => 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)} data1={costIndicator?.filter((value, index) => 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)} 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} label={months}
miniature miniature
/> />