绘制D3图时我遇到了主题错误。数据正在正确加载,因为当我执行console.log时,我可以看到数组。
使用Javascript:
d3.csv("../../shot_logs.csv", function (data) {
var shots = d3.select("svg")
.selectAll("g")
.data(data)
.enter()
.append("g")
.atrr("class", "shot")
.attr("transform", function (d) {
return "translate(" + d.x_coodinates + "," + d.y_coordinates + ")";
});
shots.append("circle")
.attr("r", 5);
});
HTML:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style-main.css" type="text/css" media="all">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://d3js.org/d3.v4.min.js"></script>
</head>
<body>
<h1>D3 Charts</h1>
<select id="selector"></select>
<svg id="canvas" height="600px" width="1200px"></svg>
<script src="JS/script.js"></script>
</body>
</html>
答案 0 :(得分:0)
看起来像一个简单的错字:)
更改
.atrr("class", "shot")
到
.attr("class", "shot")