int*_*ust 2 javascript jquery heatmap
我正在使用patrick wied的heatmapjs.我想知道如何销毁一个实例并删除由h337.create(configObject)函数创建的canvas div .
例:
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);
Run Code Online (Sandbox Code Playgroud)
我想仅销毁和删除canvas div heatmapInstance1.
目前没有方法可以销毁heatmapjs实例,但我们可以手动完成.
首先,我们必须从中删除canvas元素,DOM然后取消设置或销毁heatmapjs实例.
例:
//find corresponding canvas element
var canvas = heatmapInstance1._renderer.canvas;
//remove the canvas from DOM
$(canvas).remove();
//than unset the variable
heatmapInstance1 = undefined;
//or
heatmapInstance1 = null;
Run Code Online (Sandbox Code Playgroud)