[Chartjs]-Update the chart data from an array stored in a variable on button click

2👍

After testing several times, this seems to fix the issue:

document.getElementById("btn1").addEventListener("click",function(){
myPieChart.data.datasets[0].data = data1Arr;
myPieChart.update();
});

document.getElementById("btn2").addEventListener("click",function(){
myPieChart.data.datasets[0].data = data2Arr;
myPieChart.update();
});

Leave a comment