fixing chart
This commit is contained in:
parent
4d308ba445
commit
725b70d88f
@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
|
||||
import { Bar, Line } from 'react-chartjs-2';
|
||||
import { Bar, Line, Chart as ChartJs } from 'react-chartjs-2';
|
||||
import {
|
||||
Chart as ChartJS,
|
||||
CategoryScale,
|
||||
@ -54,9 +54,7 @@ export default function Chart({ title, data1, data2, label, subtitle, dataset1,
|
||||
plugins: {
|
||||
datalabels: {
|
||||
display: true,
|
||||
color: (value, ctx) => {
|
||||
return 'black'
|
||||
},
|
||||
color: 'black',
|
||||
formatter: (value, ctx) => {
|
||||
let sum = 0;
|
||||
const dataArr = ctx.chart.data.datasets[0].data;
|
||||
@ -86,35 +84,37 @@ export default function Chart({ title, data1, data2, label, subtitle, dataset1,
|
||||
},
|
||||
};
|
||||
|
||||
const data = {
|
||||
const data: any = {
|
||||
labels,
|
||||
datasets: [
|
||||
{
|
||||
type: 'bar',
|
||||
label: dataset1? dataset1 : '2021',
|
||||
data: data1.map(value => value.economia_acumulada? value.economia_acumulada : 0),
|
||||
backgroundColor: '#255488'
|
||||
// backgroundColor: '#255488'
|
||||
// backgroundColor: (value, ctx) => {
|
||||
// return data1[value.dataIndex]?.dad_estimado == false ? '#255488' : draw('diagonal-right-left', '#C2d5fb');
|
||||
// },
|
||||
},
|
||||
{
|
||||
type: 'bar',
|
||||
label: dataset2? dataset2 : '2022',
|
||||
data: data2.map(value => value.economia_acumulada? value.economia_acumulada : 0),
|
||||
backgroundColor: '#255488'
|
||||
// backgroundColor: '#255488'
|
||||
// backgroundColor: (value, ctx) => {
|
||||
// return data2[value.dataIndex]?.dad_estimado == false ? '#255488' : draw('diagonal-right-left', '#C2d5fb');
|
||||
// },
|
||||
},
|
||||
{
|
||||
type: 'line',
|
||||
label: 'Acumulado',
|
||||
backgroundColor: '#255488',
|
||||
label: ['Acumulado'],
|
||||
// backgroundColor: '#255488',
|
||||
data: [],
|
||||
},
|
||||
{
|
||||
type: 'line',
|
||||
label: 'Estimado',
|
||||
backgroundColor: draw('diagonal-right-left', '#C2d5fb'),
|
||||
label: ['Estimado'],
|
||||
// backgroundColor: draw('diagonal-right-left', '#C2d5fb'),
|
||||
data: [],
|
||||
}
|
||||
],
|
||||
@ -129,10 +129,9 @@ export default function Chart({ title, data1, data2, label, subtitle, dataset1,
|
||||
/>
|
||||
</RenderIf> */}
|
||||
<ChartTitle title={title} subtitle={subtitle} />
|
||||
<Bar
|
||||
<ChartJs
|
||||
options={options}
|
||||
data={data}
|
||||
/>
|
||||
data={data} type={'bar'} />
|
||||
</ChartView>
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user