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 thetext
element hasn't been rendered yet or if the container or any of its parent containers havedisplay
set tonone
at the time thetext
element is being rendered.