3

I have a chart where I want to display text tooltips of variable lengths as long as 300 characters, but they are displayed with random box sizes. Sometimes they are shown in a neat square box with several lines of text, which is nice. But sometimes they attempt to put all the text in one line and it doesn't fit in the chart, so some part of the text is not visible.

I wonder if there is a way to format the tooltip box to a fixed maximum width to avoid this problem.

Below are two pictures showing the same chart. The first one shows a tooltip box out of the chart and page, so the complete text is not visible. The second one shows another tooltip that randomly shows the text fine.

This one doesn't show all the text This one has all the text visible

Note: I tried cutting the text to a fixed length of 50 or 80 characters and it's better, but I would prefer to have the complete text.

joelostblom
  • 43,590
  • 17
  • 150
  • 159
flbyrne
  • 181
  • 1
  • 9
  • 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. [There is a workaround for linebreaks in legend labels](https://github.com/vega/vega-lite/issues/6739#issuecomment-658542379) which might also work in tooltips, but I don't think you can express that vega-lite in altair.
    – joelostblom Jun 15 '21 at 15:34

0 Answers0