0👍
The correct method to use, in order to be able to draw another chart on the same canvas, is .destroy()
. You must call it on the previously created chart object. You may also use the same variable for both charts
var grapharea = document.getElementById("barChart").getContext("2d");
var myChart = new Chart(grapharea, { type: 'bar', data: barData, options: barOptions });
myChart.destroy();
myChart = new Chart(grapharea, { type: 'radar', data: barData, options: barOptions })
- Chartjs-LinearGradient doesnt't work on chartJs canvas for Angular
- Chartjs-Chart.js Version 3: how to set the different color for tick lines and gridlines
Source:stackexchange.com