[英]Heatmap.js clickable heatmap
我正在使用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>
在他們的示例中,看起來他們的div
包含一些樣式定義和一個類:
<div id="heatmapArea" class="well" style="width:610px;padding:0;height:400px;cursor:pointer;position:relative;"></div>
但是,您可能只需要向div
添加height
和width
。
這是一個例子
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.