Chartjs-Destroying chart.js is not working when chart created inside function – chart.destroy() is not a function

3πŸ‘

βœ…

Set window.chart = rather than relying on the implicit function of chart =. If you were using strict mode with your code, it should throw a warning.

0πŸ‘

Take a look at this: https://github.com/chartjs/Chart.js/issues/1007

Change:

var myNewChart1 = new Chart(ctx1).Line(barChartData1, {animation: false});

To:

window.myNewChart1 = new Chart(ctx1).Line(barChartData1, {animation: false});

0πŸ‘

for me using jQuery, I just did $("#container").html="";

Leave a comment