Why Are The .selectall() D3-created Circles In My Svg Said To Be 1 Element Using .length?
I suspect that the answer lies somewhere between my ignorance of what kind of object I'm actually working and the inner darkness of D3 and/or SVG. I can see 30 circles on the scree
Solution 1:
var circles = d3.select("#svg1").selectAll("circle");
circles
is an array of array, hence the length is 1
. That is the length of the outer array. If you want to get the count of circles selected then you should use d3
s built-in method size
.
var count = d3.select("#svg1").selectAll("circle").size();
This will give you the expected result.
Post a Comment for "Why Are The .selectall() D3-created Circles In My Svg Said To Be 1 Element Using .length?"