Hello I tried to integrate this d3 zoomable treemap from
http://mbostock.github.io/d3/talk/20111018/treemap.html
but the getComputedTextLength()
always returns 0. I also tried getBBox()
, but it returns an object with all properties with zero.
.text(function(d) { return d.name; })
.style("opacity", function(d) {
d.w = this.getComputedTextLength();
return d.dx > d.w ? 1 : 0;
});
Do I need to put my text wrapped in a tspan
?
What other reasons could generate this?
I realize that this is over a year late, but I ran into the same issue recently and this may help someone. this.getComputedTextLength()
returns 0 if the text
element hasn't been rendered yet or if the container or any of its parent containers have display
set to none
at the time the text
element is being rendered.
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