Clip SVG text to width of rectangle in a D3 treema

2019-04-06 09:49发布

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:

enter image description here

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.

1条回答
我想做一个坏孩纸
2楼-- · 2019-04-06 10:32

You could wrap each <rect> element in an <svg> element of the same width/height. By default overflow is hidden on inner <svg> elements.

查看更多
登录 后发表回答