将SVG文本剪切到D3树形图中的矩形的宽度 [英] Clip SVG text to width of rectangle in a D3 treemap
问题描述
我想知道是否有一个更简单的方法来限制文本标签的宽度,而不是使用剪辑路径。
这里是一个例子寻找有关标签:隐藏在内部< svg>
元素。
I'm wondering if there is a simpler way to restrict the width of a text label than using a clip path.
Here's an example of what I'm looking for with regard to labeling: treemap:
Notice that the labels get truncated by the boundaries of the containing tiles.
That particular example is implemented using <div>
tags, which have this behaviour by default. But I'm using SVG <rect>
and I'm hoping there is a more straight-forward way of doing this than a separate clip path defining another rect shape.
You could wrap each <rect>
element in an <svg>
element of the same width/height. By default overflow is hidden on inner <svg>
elements.
这篇关于将SVG文本剪切到D3树形图中的矩形的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!