简体   繁体   中英

heatmap.js clear existing map

I'm using heatmap.js which can be found here:

http://www.patrick-wied.at/static/heatmapjs/index.html

Anyways I've been able to create a heatmap successfully - now my problem is with resetting the data inside of an existing map - I want to clear it without creating a new object, but I can't seem to figure out how to do it. All I know is how to set a data array, but I can't clear one.

Thanks!!

I don't know if there's a built in way to do it, but you can use .setDataSet method and pass object with empty array of datapoints:

heatmap.store.setDataSet({data:[]});

Demo: http://jsfiddle.net/ygalanter/UpbKH/2/

有一个内置的方法.clear() ,你可以使用

To anyone who still wants an answer to this question. I did not seem to find any direct method of clearing the map. The canvas that is used to draw the graph has a class name of "heatmap-canvas". So before you plot a new heatmap, run the following block of code to delete all previous heatmap canvas.

[...document.getElementsByClassName("heatmap-canvas")].forEach((e) =>
  e.remove()
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM