我在地图上有一组圆圈,如10个红色圆圈,10个蓝色圆圈,10个绿色圆圈.如何使用d3 selectAll仅选择红色圆圈或选择?
或者还有其他方法吗?
颜色已经这样给出(作为"样式"属性中"填充"的值,
feature = g.selectAll("circle")
.data(data)
.enter().append("circle")
.attr("id", function (d) {
return d.ArtistID + d.FollowerID;
})
.style("stroke", "black")
.style("opacity", .6)
.style("fill", function (d) {
if (d.ArtistID == 1) {
return "red"
} else if (d.ArtistID == 2) {
return "blue"
} else {
return "green"
};
})
.attr("r", 10);
Run Code Online (Sandbox Code Playgroud)
所以,圆圈会像这样绘制,
<circle id="10" r="10" transform="translate(695,236)" style="stroke: rgb(0, 0, 0); opacity: 0.6; fill: rgb(255, 255, 0);"></circle>
Run Code Online (Sandbox Code Playgroud)
我想选择红色的圆圈.Cam有人帮忙吗?
提前致谢.