Function: wrapTextRuns()
function wrapTextRuns(lines, font, maxWidth, options?): readonly TextRun[][];Experimental
Word-wrap rich lines to maxWidth px: Plotly's wrapText (table cells) made run-aware, so rich labels can wrap like plain ones.
Every line (a <br> already ends one) is split at spaces, whichever run holds them; a word may span runs (<b>bold</b>face is one word). Lines are filled greedily, each word counting its width plus one space (measured between two letters in the font of the run the word ends in, since widths exclude trailing whitespace), and break before a word that would pass maxWidth. A word wider than maxWidth gets a line of its own and is not broken. Each piece keeps its run's style (font, color, shift, link); the space between two words on one line keeps the style of the run it came from, and the space at a break is dropped. A line that needs no break is returned as it is (same run objects).
With one plain run per line, the result's text is exactly what the plain-text wrap gives.
Parameters
| Parameter | Type |
|---|---|
lines | TextRunLines |
font | TextFont |
maxWidth | number |
options | TextRunWrapOptions |
Returns
readonly TextRun[][]