0

I have a chart where I want to display long text as tooltips. The text contains a couple of sentences, I therefore would like to specify a line break or the width of the tooltip box. Currently the tooltip is displayed as a single line having a width that exceeds the browser window and is therefore not readable.

Update:

As a workaround I could solve this by simply encoding the tooltip channel as an array. Instead of having

Chart.encode( tooltip=alt.Tooltip('field', title='title') )

using the following syntax solved the issue and created a tooltip box for even long text

Chart.encode( tooltip=[alt.Tooltip('field', title='title')] )

scapi
  • 21
  • 4
  • It doesn't seem like Vega supports `\n` or `
    ` or other ways to split long strings atm so you can suggest this feature on their issue tracker. This is question is a duplicate of https://stackoverflow.com/questions/65798037/altair-tooltips-is-there-a-way-to-format-box-shape-for-long-text
    – joelostblom Jun 11 '21 at 17:22
  • Thank you! Regarding the duplicate issue: I could not "comment" this question, so I wrote an "answer" asking whether this has been solved. Unfortunately my post was deleted because "This does not provide an answer to the question." So I created a new one – scapi Jun 15 '21 at 08:28
  • 1
    I see, the best thing you can do in that situation is to upvote the previous question so that it gets more attention and it is more likely that someone will notice it and provide an answer. – joelostblom Jun 15 '21 at 15:36

0 Answers0