1

所以我正在渲染一些具有特定width120px 的对象,并且这些对象将具有不同的标题。我的问题是当标题太长时,它不会将其换行并将其放在新行中。svg中是否有解决此类问题的方法?

var labels = ["Testing 123", "Things are fantastic"]

for (var i = 0; i < labels.length; i++)
            {
                cell = editor.graph.cloneCells([cell])[0];
                // cell.setStyle(new-style);
                editor.graph.model.valueForCellChanged(cell, label);

                editor.toolbar.addPrototype(label, "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='43px' width='104px'>" +
                    "<rect fill='#595A5A' stroke='black' x='0' y='0' rx='5' ry='5' width='100%' height='100%'/>"+
                    "<text text-anchor='middle' font-weight='600' font-family='Helvetica' fill='#BCCF00' x='50%' y='25' font-size='12'>" + label + "</text></svg>", cell);
            }
4

1 回答 1

3

SVG 1.1 中没有自动文本换行。您需要自己将文本布局成行。

于 2016-08-24T20:15:49.680 回答