Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting an id issue in d3

Tags:

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?

like image 879
user1782677 Avatar asked Nov 02 '12 02:11

user1782677


1 Answers

I figured it out, apparently ids can't start with a number.

like image 117
user1782677 Avatar answered Oct 07 '22 21:10

user1782677