interstellarDust interstellarDust - 1 year ago 210
jQuery Question

How to destroy heatmap.js instance?

I'm using patrick wied's heatmapjs.
I want to know how to destroy an instance and remove the canvas div created by



var config = {
container: document.getElementById('heatmapContainer'),
radius: 10
var config2 = {
container: document.getElementById('heatmapContainer'),
radius: 5
var heatmapInstance1 = h337.create(config);
var heatmapInstance2 = h337.create(config);
var heatmapInstance3 = h337.create(config2);

I want to destroy and delete canvas div only for

Answer Source

Currently there is no method to destroy a heatmapjs instance, but we can do that manually.

First we have to remove the canvas element from DOM and than unset or destroy the heatmapjs instance.


//find corresponding canvas element
var canvas = heatmapInstance1._renderer.canvas;
//remove the canvas from DOM
//than unset the variable
heatmapInstance1 = undefined;
heatmapInstance1 = null;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download