Chartjs-How to remove old chart and append new chart to div using chartjs

1👍

You can use the API method getChart to see if it exists. If it does not exist it will return undefined, if it does exist it will return that chart.

So you would get:

const tmpChart = Chart.getChart('canvasID');
if (tmpChart) {
  tmpChart.destroy()
}

Leave a comment