3

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?

Sam
  • 2,275
  • 9
  • 30
  • 53

1 Answers1

0

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.

Ash
  • 672
  • 6
  • 21
  • Yeah, this should work and this is my final solution, is there any possibility to fit text with in the current width and height? – Sam Jul 18 '18 at 06:26
  • well if you are going to fix some particular width and height, then after a point text will always get out of node. You could use white-space property like this: label: '
    , it will help changing line. Happy to help.
    – Ash Jul 18 '18 at 07:00