我使用Heatmap.js创建可点击的热图。我尝试以下代码失败。
正在显示图例,但单击画布并没有像预期的那样生成热图。
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="heatmap.js"></script>
</head>
<body>
<script type="text/javascript">
window.onload = function(){
// heatmap configuration
var config = {
element: document.getElementById("heatmapArea"),
radius: 30,
opacity: 50,
legend: {
position: 'br',
title: 'Example Distribution'
}
};
//creates and initializes the heatmap
var heatmap = h337.create(config);
document.getElementById("heatmapArea").onclick = function(e){
heatmap.store.addDataPoint(e.layerX, e.layerY, 1);
};
};
</script>
<div id ="heatmapArea">
</div>
</body>
</html>