0
得分我有一個geoJSON的郵政編碼質心點,我正在繪製一個D3.js地圖。我可以讓他們顯示,但我無法調整點的大小。我假設.attr(「r」,1)會這樣做,但我必須錯過一些東西。在地圖上用D3.js
d3.json("ZipPoints.json", function (zipPoints) {
svg.selectAll("g")
.data(zipPoints.features)
.enter()
.append("path")
.attr("d", path)
.attr("r", 1)
.style("fill", "red");
});
編輯:
d3.json("ZipPoints.json", function (zipPoints) {
points.selectAll("circle")
.data(zipPoints.features)
.enter()
.append("circle")
.attr("r", 1.5)
.attr("transform", function(d, i) {
return "translate(" + projection(zipPoints.features[i].geometry.coordinates) + ")";
})
.style("fill", "red")
.classed("point", true);
});
爲什麼追加「路徑」元素而不是圓圈? – tomtomtom
我不知道,我從來沒有這樣做過。那是我應該做的嗎?我將「路徑」更改爲「圈子」,我的觀點不渲染。 – bailey
它看起來像你在GeoJSON中實際定義爲路徑的「點」。在這種情況下,正確的方法是修改GeoJSON來增加標記的大小,儘管你可以通過增加筆劃寬度來修改它。 –