I have a stacked barchart that I produced with a nested selection/d3.nest datastructure and was wondering what the best idiom for
getting information about the parent (in this case the parent's index) from the child was. I'm using the following, which seems to work:
in the parent:
.attr( "data-idx", function( d, i ) { return( i ); } )
in the child which is nested inside two <g>'s:
var idx = +d3.select( this.parentNode.parentNode ).attr( "data-idx" );
Is this considered good form or is there a better way to do it?