plot icon indicating copy to clipboard operation
plot copied to clipboard

Allow the tip title channel to contain rich text or markup

Open aborruso opened this issue 2 years ago • 18 comments

Hi, I would like for example to have in bold the first line of tooltip (it’s a title) and to add a hyperlink at the end of the tooltip text.

I think it would be very helpful and informative.

Thank you

image

aborruso avatar Jul 23 '23 18:07 aborruso

It would be very cool if one could use a feature like the one suggested here to put a plot inside of a tooltip – eg. imagine a scatterplot where each dot represents a group of datapoints, and hovering on a datapoint can show you more details about the points inside that particular group (eg. the distributions of some other variables).

yurivish avatar Jul 25 '23 17:07 yurivish

Saw this interesting use of tippy to generate html tooltips for Plot.

https://observablehq.com/d/baeb8cbead1ed3d2

CobusT avatar Jul 25 '23 19:07 CobusT

Just to add a bit to this (I was encouraged to post here by @Fil): it would be very nice to be able to have "aggregated" tips, where pointerX somehow allows us to report all values on the chart at the X position the mouse cursor exists at. Like this:

Screenshot 2023-08-07 at 2 54 23 AM

Happy to try to work on this together if people are interested in this.

hausdorff avatar Aug 07 '23 10:08 hausdorff

Here’s an example of grouped tips: not as complete as what you're suggesting, but I'm using Plot to generate it so it's easy to expand with marks and transforms. https://observablehq.com/@recifs/plot-grouped-tips

Fil avatar Aug 07 '23 12:08 Fil

Upvoting as I also have a use case for rich text, etc tool tips. In particular, I want to be able to embed images or custom marks in the tooltip. Thanks!

joe-bruce avatar Aug 16 '23 22:08 joe-bruce

@joe-bruce Can you please also upvote by adding a 👍 reaction to the top post? That way we can track the number of upvotes by sorting issues. Thank you.

Screenshot 2023-08-16 at 3 30 31 PM

mbostock avatar Aug 16 '23 22:08 mbostock

@aborruso - this may help you also: https://observablehq.com/@mtsvelik/clickable-hyperlinks-in-plot-tip

mishatsvelik avatar Sep 20 '23 15:09 mishatsvelik

Something relatively “easy” we could do: a custom format function for a channel value could return an SVG TSPAN or A element, allowing the text to be styled and hyperlinked. Essentially we’d change this line here to append the returned value directly rather always wrapping it in a text node:

https://github.com/observablehq/plot/blob/f55155b779840df961e2ff1f1f12afb7b41081d4/src/marks/tip.js#L197C18-L197C68

mbostock avatar Sep 20 '23 16:09 mbostock

Hi @mbostock, does the great latest release - "The new format tip mark option enables greater control over order and formatting of channels." - help me to reach my goal or part of it?

I think yes, but before getting emotional, I wanted to be certain.

Then I'll have to figure out how to use it, because I'm too bad at it. But at least I'm poor, but happy.

What do you think: should I close this issue?

aborruso avatar Sep 20 '23 17:09 aborruso

No @aborruso, the new custom format is still limited to plain text formatting, not rich text. Sorry! That is why we have this separate issue.

mbostock avatar Sep 20 '23 18:09 mbostock

Another direction to explore here could be a content channel that returns arbitrary SVG content. This would take priority over the default display (similar to the title channel taking priority over the default display of all channels), and allow rendering arbitrary content albeit using a lower-level API — for example, you could generate SVG foreignObject elements using htl.svg.

mbostock avatar Sep 22 '23 15:09 mbostock

If the href channel exists, the tip should open the page (maybe with a second click on a link icon?)

Fil avatar May 04 '24 01:05 Fil