I have various SVG <g>
objects, each with a <circle>
child and a <text>
child. I can use select()
to find a particular <text>
object, by the class attached to it, and then modify it:
d3.select('text.my-class')
.classed("my-class",false).classed("new-class",true)
.text("Next Stage!")
;
Now I need to modify it's circle sibling. The circle has no particular identifying class (hhmmm... perhaps giving it one would be the d3 way of doing this?), so my first try was jQuery-like:
d3.select('text.my-class').parent().select('circle')
.attr('style','fill:#f00;')
;
That fails with "parent is not a function".
The answer to a similar question ( How to select parent element of current element in d3.js ) suggested this.parentNode
, but either I'm using it wrong or it does not work here. I've tried both of these:
d3.select('text.my-class').select(parentNode).select('circle')
d3.select('text.my-class').select(this.parentNode).select('circle')