Suppose we have an array like ['05/Feb/2019', '05/Feb/2019', '05/Feb/2019', '01/Feb/2019'] for Labels and another array with values like ['2', '5', '7', '4']. Is there a way to display only one column for all the elements '05/Feb/2019' while summing up their corresponding values in that column?
CHART JS CODE SNIPPET
myChart = new Chart(document.getElementById("canvas"),{
"type":temp.type,
"data":{
"labels":column_a,
"datasets":[{
"label":label_b,
"data":column_b,
"spanGaps": true,
"fill":false,//true for charts like radar and polar area
"backgroundColor":["rgba(255, 99, 132, 0.4)","rgba(255, 159, 64, 0.4)","rgba(255, 205, 86, 0.4)","rgba(75, 192, 192, 0.4)","rgba(54, 162, 235, 0.4)","rgba(153, 102, 255, 0.4)","rgba(201, 203, 207, 0.4)"],
"borderWidth":1
}
]},
"options":{
tooltips: {
callbacks: {
label: (tooltipItem, myChart) => {
const realValue = myChart.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
//const customValue = realValue.toFixed(2).replace(".", ",") + '%';
const customValue = realValue.toFixed(2).replace(".", ",");
const label = myChart.labels[tooltipItem.index] + ':';
return label + customValue;
}
}
},
"scales":{
"yAxes":[{
"gridLines":{display:false},
"ticks":{
"suggestedMin":0,
"max":max_value_1
}}]}
}});
window.myChart = myChart