I would like to read the width of <text>
elements, created in d3, after they're created.
I have tried
svg.selectAll("text")
.each(function () {
console.log('text', d3.select(this).style("width"));
}); // 'auto'
and
svg.selectAll("text")
.each(function () {
console.log('text', $(this).css("width"));
}); // '0px'
Thanks in advance
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With