d3.js - Get group from D3js selectAll in console? -
in context of understanding better details of d3.js, bit puzzled how selectall
works.
for example, based on codepen, possible write:
vis.selectall("circle.nodes")
or:
vis.selectall("my_own_tag_group")
but after d3js code executed, expect selectall
gives group access web console too:
document.getelementsbyclassname('my_own_tag_group') htmlcollection [ ] (empty)
what missing explanations given in http://bost.ocks.org/mike/selection/
at least code, looks you're doing selection wrong. selectall
follows css3 selector rules:
d3 uses css3 select elements. example, can select tag ("div"), class (".awesome"), unique identifier ("#foo"), attribute ("[color=red]"), or containment ("parent child"). selectors can intersected (".this.that" logical and) or unioned (".this, .that" logical or). if browser doesn't support selectors natively, can include sizzle before d3 backwards-compatibility.
therefore, you'd want use
vis.selectall(".my_own_tag_group")
if refers class, ,
vis.selectall("#my_own_tag_group")
if refers id (which might either make sense or not).
if refers else, might want restructure refers class.
Comments
Post a Comment