I am trying to create a SimpleLabelStyle
with the word wrapping
enabled, as the second box of the interactive demo. However, I am not able to reproduce it.
I am trying:
var /**yfiles.drawing.SimpleLabelStyle*/ simpleLabelStyle = new yfiles.drawing.SimpleLabelStyle();
simpleLabelStyle.trimming = yfiles.system.StringTrimming.WORD;
But it's not working. In fact, in the documentation, I see that trimming "gets the value that determines how to trim the text." (it just says "gets" and not "sets").
Any help is appreciated!
Actually you can set the value - this documentation is misleading here. The property is declared READ-ONLY
in the interface (see the badge):
ISimpleLabelStyle.trimming API
But the instance that you have instanciated implements the interface and makes the property READ-WRITE
. Unfortunately the documentation is inherited from the interface and the only indication that the property is READ-WRITE is that the READ-ONLY
badge is missing in the API browser. Any property that is not READ-ONLY
or WRITE-ONLY
is implicitly readable and writable so setting the value will work using the property on the instance (SimpleLabelStyle.trimming API)
Note that if you are changing the value for an existing style, the change will not immediately be visible. You should invalidate the graph's displays using the IGraph.invalidateDisplays() API
var style = new yfiles.drawing.SimpleLabelStyle()
style.trimming = yfiles.system.StringTrimming.ELLIPSIS_WORD;
graph.setLabelStyle(label, style);
// and later
style.trimming = yfiles.system.StringTrimming.ELLIPSIS_CHARACTER;
graph.invalidateDisplays();