Imran Qamer Imran Qamer - 2 months ago 21
CSS Question

How to unrender/detach/remove ZingChart library from specific div?

I used below code to render zingchart which works fine.

zingchart.render({
id : 'myChart',
data : myConfig,
height: 400,
width: "100%"
});


Now in some occasion I want to un render or detach it. I Mean when I click on some specific place this div with id
myChart
should be empty and zing chart should be removed from it.

How can i achieve it?

I tried this jquery code as well.

$("#myChart").html('');


Thanks in advance.

Answer

Full disclosure, I'm a member of the ZingChart team.

Deleting the DOM element the chart is attached to will not delete the chart from memory. At this point you will have something along the lines of a dangling reference. You achieve proper destruction using our api method destroy

zingchart.exec('myChart','destroy');