react-sigma icon indicating copy to clipboard operation
react-sigma copied to clipboard

Line breaks for long labels

Open pann-q opened this issue 1 year ago • 1 comments

Good day. Sigma must be able to do line breaks for long labels. For example, it can specify the maximum label length in the parameter

Is your feature request related to a problem? Please describe. We have very long labels and need to display them in several lines

Describe the solution you'd like It can specify the maximum label length in the parameter

Describe alternatives you've considered We tried adding \n, but it doesn't work

pann-q avatar May 29 '24 18:05 pann-q

Labels are displayed in canvas in sigma, and it uses the function filltext which doesn't support line breaks. So there is no native support for your need.

You can write your own label renderer which is simple, it's just one function. There is an example here :

  • function example : https://github.com/jacomyal/sigma.js/blob/main/packages/demo/src/canvas-utils.ts#L95
  • define it in the settings : https://github.com/jacomyal/sigma.js/blob/main/packages/demo/src/views/Root.tsx#L38

You can do the same thing for the drawHover. It's what is used in the demo of sigma website

sim51 avatar May 30 '24 09:05 sim51