|
TextBox.setTruncate splitting in middle of word |
Posted by Naveen on Oct-25-2016 04:47 |
|
I'm trying to lay out multiple bar chart with a label for each one (using chart.addText()). In order to make it look clean I'm using setTruncate on the labels for the charts, but in some cases setTruncate looks like it's splitting the text in the middle of the word. In the example in the image, each textbox on the left has setTruncate(80, 2) called.
|
Re: TextBox.setTruncate splitting in middle of word |
Posted by Peter Kwan on Oct-26-2016 04:07 |
|
Hi Naveen,
If you use setTruncate(80, 2), then ChartDirector will break the text into two lines if it is longer than 80 pixels. It will always truncate at a space character to ensure the line is less than 80 pixels. However, if there is no space character, then it has no choice but to break at a non-white space position. This is the commonly accepted behaviour for text layout (eg. Microsoft Word will wrap in the same way).
For your case, the text "Repurchased" is probably longer than 80 pixels, and there is no space in the text, so it can only be wrapped by breaking it into two lines.
Regards
Peter Kwan |
Re: TextBox.setTruncate splitting in middle of word |
Posted by Naveen on Oct-27-2016 22:22 |
|
Ah, ok that makes sense. I was hoping that if it couldn't lay out the text in 2 lines (because that would require splitting a word in the middle) then it would use ellipses, otherwise it would use multiple lines for each text (but keeping words whole). |
|