Clip SVG text to width of rectangle in a D3 treemap

雨燕双飞 提交于 2019-12-09 16:21:54

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/11023417/clip-svg-text-to-width-of-rectangle-in-a-d3-treemap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!