score:1

Accepted answer

.attr("class", function(d,i) { return d3.select(this.parentNode).attr("class"); })

As described in a similar question, this.parentNode gives you the <g> domain tree element itself, but what you need is a D3-wrapped object that supports calls to D3-specific functions such as .attr.

Also note that this isn't defined as usual in the arrow shorthand format but points to the surrounding context, as described in MDN.


Related Query

More Query from same tag