繁体   English   中英

D3.JS为每个国家添加课程

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM