[英]D3.JS add class to each country
我正在使用它进行简单的可视化。
http://bl.ocks.org/KoGor/5994804
我想在每个国家的路径上添加他的名字。 我试图遍布各国,但我不知道与SVG联系。
var world = svg.selectAll("path.land")
.data(countries)
.enter().append("path")
.attr("class", "land")
.attr("d", path)
您可以使用函数为每个数据项动态构建class
属性:
var world = svg.selectAll("path.land")
.data(countries)
.enter().append("path")
.attr("class", function(d) { return "land " + d.name })
.attr("d", path)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.