read width of d3 text element
In a selection method (such as attr) :
this.getComputedTextLength().
In a selection of one element, you can say
selection.node().getComputedTextLength().
You can also use getBBox for the width and height