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