How to set width of text marks in vega-lite / altair (text wrapping and line break) for long text - visualization

I am trying to display text over time using altair (vega-lite), which works fine using a layered chart, where one is created using the alt.Chart().mark_text() function to display the text.
The text though is multiple phrases and should be wrapped (with line breaks). How can this be done?
(I do not want to use fixed line breaks, e.g. \n, at distinct positions since the text wrapping should work with zooming too)

Not exactly what you want, but you can specify a character on which to break to a new line. When zooming, the text stays the same size, so it should always fit the view.
For example making a new line for every word:
.mark_text(lineBreak=' ')

Related

Set custom breakpoints in long String during dynamic resize

I have a string of text that dynamically resizes. At its core its basically a Text widget in a SizedBox in a Column.
When it resizes, the words wrap to the next as you typically expect...it breaks to the next line by using the 'SPACES' between words (as opposed to breaking up words character by character).
However, an email address can be a very long string without spaces. When it no longer fits within the bounds of the box it begins to resize itself by breaking on individual characters and moving into the next line.
It's a minor issue, but not visually appealing.
How might one create breakpoints within the String to resize itself by wrapping to the next line based on custom characters? For example, in an email address I'd prefer it break on the '#' and/or '.' before resorting to breaking up the String on individual characters.

WKInterfaceLabel ignoring \n indicators

I'm getting text from the MediaWiki API, and it includes getting \n text which indicates a new line. When I set the API results as the text of a WKInterfaceLabel, the \n's disappears, but no new line is created.
Any way to fix it?
Example. From this term:
[...] forms.\n\n==Use in writing systems==\n\n===English===\nIn Modern English [[English orthography|spelling]], {{angbr|i}} represents several different sounds, either the diphthong {{IPAc-en|aɪ}} ("long" {{angbr|i}}) as in ''kite'', the short [...]
It's meant to remove the \n's and replace it with new lines. What's added to the label is this text minus the \n's, but no new lines.

How to indent if Text is softWrapped in Flutter

I'm working on an app that displays lyrics for several hymns in my native language.
Each line of the hymn is an individual Text Widget. I want the text to indent if it got softWrapped if user increases the font size to indicate that its not the next line. How can I achieve this effect?
Adding one or more tab escape characters "\t" to your strings may do the trick for you:
Text("\t this is a text string that will have an indentation",),

Matlab text object carriage return issue + text outside graph

I'm trying to show some text on top of a plot. Using
text(13,15200,('~ 12h'),'HorizontalAlignment','right','VerticalAlignment','middle','FontSize',10,'FontAngle','italic');
I can create the text box how I want it. But a thing I didn't manage to do is to create a carriage return within that text object. Already tried to add '\r' or '\n' but the only thing I get is the display of '\r' or '\n' with out breaking the line. Any ideas?
And i now that text object are used to put text WITHIN axes. But I am still trying to find a way to put some text outside the grap. Searching stackoverflow I found this Post about using UICONTROL. It works great but when I export to EPS the text seems to be in pixel format and NOT vector - so it looks really bad. Is there another way besides using uicontrol??
Thanks a lot for help!
In text that is not interpreted, you can specify line breaks using the carriage return character, which has the ascii code 10.
text(x,y,sprintf('break after this%snew line here',char(10)));
To allow text outside axes, you need to turn off clipping for the text object
text(x,y,.....,'clipping','off')

Multi-line button labels

Is there an easy way to have two lines of button.text where you specify each line individually? Also, there seem to be large margins on the buttons so the text font needs to be quite small to fit. Is there a way to allow the text to use more of the button area?
The way I would do a two-line text implementation is:
Dim t1,t2 As String
t1="This is line one"
t2="This is line two"
...
MyButton.Text = t1 & CRLF & t2
The CRLF performs a Carriage Return and Line feed thus splitting the text up
I can't help with the padding issue though. Have you tried changing the font size?
MyButton.TextSize=9