So this is what I'm doing:
selection = canvas.selectAll("circle").data(mydata) selection.enter().append("circle") selection .attr("id", function(d, i){ var result = i+''; return result; })
In short, I'm trying to set the id of each element to be a string representation of its index.
However, when I try to access that particular element later by using d3.select("#1")
or by using a number variable i and going d3.select("#" + i.toString())
, nothing seems to work.
What am I doing wrong?
I figured it out, apparently ids can't start with a number.
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