我一定遗漏了一些明显的东西,但我无法显示<text>
。看见http://jsfiddle.net/ydaLh/用于HTML+CSS
<svg style="width: 320px; height: 200px; top: 0px; left: 0px; position: relative;">
<g class="depth">
<g class="children">
<rect class="child" x="99" y="0" width="47" height="30">
<text dy=".75em" x="105" y="6">PRIMARY</text>
</rect>
<rect class="child" x="90" y="0" width="8" height="30">
<text dy=".75em" x="96" y="6">MASTER</text>
</rect>
<rect class="parent" x="90" y="0" width="56" height="30"></rect>
</g>
</g>
</svg>
基于http://bost.ocks.org/mike/treemap/
在SVG中,您没有在图形元素中嵌套文本元素,您必须具有类似于以下内容的内容:
svg
.append("rect")
.append("text");
但你实际上需要:
svg.append("rect");
svg.append("text");