我正在尝试使用 heatmap.js 绘制 x1,y1 坐标,我使用 d3.csv() 方法从 .csv 文件中读取值。我尝试了https://www.patrick-wied.at/static/heatmapjs/中的示例,仅绘制了一个点,但 .csv 文件中有七个点。下面是代码。
enter code here
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script src="heatmap.js"></script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript">
function point()
{
alert("alert");
var points = [];
var heatmap = h337.create({
container: domElement
});
d3.csv("files/trial5.csv", function(error,data) {
data.forEach(function(d) {
d.x1 = +d.x1;
d.y1 = +d.y1;
console.log("data : " +data + " " + error);
heatmap.setData({
max: 5,
data:[{ x: d.x1, y: d.y1, value: 5}]
});
console.log("x:" + d.x1, "y:" + d.y1);
})
});
}
</script>
</head>
<body>
<div id="domElement" style="width: 1000px; height: 1000px; border: solid;"></div>
<input type="button" value="Click" id="clickButton" onclick="point()"/>
</body>
</html>