destroy()

Removes the chart references internally, thus making the chart eligible for garbage collection, in turn clearing up the memory.


Example: chart.destroy();

Note:
  • On calling chart.destroy(), chart won’t be responsive unless new chart is created.
  • chart.destroy() should be called before using the same variable to hold a newly allocated object/chart to prevent memory leaks.

var  chart =  new  CanvasJS("container",
{
    .
    .
    .
    .
});
chart.render();

chart.destroy();
chart = null;

Try it Yourself by Editing the Code below.

  Also See:    



In order to provide better support,we have closed the comments and switched completely to our Forums.
If you have any questions, please feel free to ask in our forums.