CDU-data-science-team / pxtextminingdashboard

Text mining and visualization of NHS patient feedback.
https://feedbackmatters.uk/rsconnect/text_mining_dashboard/
Other
4 stars 1 forks source link

Increase size of plotly tooltip #6

Closed andreassot10 closed 3 years ago

andreassot10 commented 3 years ago

Users have asked us to hide the feedback text, as they would prefer it to show on hover.

The plotly tooltip does not fit the text. Unfortunately, setting layout.hoverlabel.align.namelength to -1 does not work entirely, as all it does is it overstretches the tooltip to fit the text in a single line.

I developed a function to break the text into several lines per, e.g. 6 tokens (I may change this number). It works for shorter texts only- a long text occupies several lines, causing the tooltip to not even show on hover.

It appears that there is a limit to how much the tooltip can be stretched vertically. I do not know how to control this limit and I suspect that a more invasive approach (JavaScript?) may be required.

Note: Even with the bug, the script runs with no problems, although the tooltip will not show on hover.

@ChrisBeeley will probably be able to help with this. @andreassot10 to contact as soon as possible.

andreassot10 commented 3 years ago

These may help: https://gitlab.com/snippets/16220 https://github.com/nhs-r-community/shiny-training/blob/main/a_and_e_original_interactive/app.R

andreassot10 commented 3 years ago

First attempt to add tooltips based on this is partly successful.

Problem is that the feedback text and every other single value (e.g. the comment's tag) will appear on the tooltip ten times, i.e. as many times as the number of NRC sentiments.

Also, sometimes text is too long, and thus tooltip is too big, so the cursor and the tooltip overlap, which makes the latter disappear only shortly after hover.

Finally, it has been really tricky to position the tooltip for each plot at the appropriate place near the facet of interest. Tooltips for facets on the right hand side are outside the limits of the app's width.

Try this: instead of using tooltips, make a text box appear in the middle of the plot when user clicks on it. Like zoomedGraph.