0👍
✅
Try destroying the old chart instance before creating a new one, using the destroy()
method.
...
if (myChart) myChart.destroy();
myChart = new Chart(ctx, {
type: 'line',
...
...
make sure the myChart
variable is globally accessible
However, a better approach would be to update your chart using the update()
method, when you add/update any data in your chart, instead of creating a new instance of chart everytime.
Source:stackexchange.com