简体   繁体   中英

dagre-d3- make the long text to fit inside node

In the setNode we can specify the html as well. if i mention width and height, and if it a long text, it is moving out.

g.setNode(0, {
    labelType: "html",
    label: '<div style="color: red; width: 90px; height: 30px;">test data overlapping</div>',
    width: 70,
    height: 35
});

I tried to give width to the div but it is not working sample Fiddle

How can i make the text to fit inside node?

Use the auto property on width and height like this:

Sample Fiddle

using auto the element will automatically adjust its height and width to allow its content to be displayed correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM