0👍
✅
You’re updating each dataset, and feeding it’s data
with the new dataset. Also, the labels should also be provided on the chart itself, instead of the dataset items.
The correct way would be
function changeData(index) {
var data = dataObject[index];
chart.data.labels = data.label;
chart.data.datasets = data.datachart;
chart.update();
}
👍:0
function changeData7(index) {
chart7.data.datasets.forEach(function(item, indexs) {
item.label = dataObject[index].datachart[indexs].label;
item.data = dataObject[index].datachart[indexs].data;
});
chart7.update();
}
I do this but if i call changeData7(0)
, data doesnt change to index 0