I'm using this for a simple visualisation.
http://bl.ocks.org/KoGor/5994804
I want to add the country's name to each path. I've tried to loop over countries, but I have no idea how to link with the SVG.
var world = svg.selectAll("path.land")
.data(countries)
.enter().append("path")
.attr("class", "land")
.attr("d", path)
You can use a function to build the class
attribute dynamically for each data item:
var world = svg.selectAll("path.land")
.data(countries)
.enter().append("path")
.attr("class", function(d) { return "land " + d.name })
.attr("d", path)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With