Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the tip title channel to contain rich text or markup #1767

Open
aborruso opened this issue Jul 23, 2023 · 13 comments
Open

Allow the tip title channel to contain rich text or markup #1767

aborruso opened this issue Jul 23, 2023 · 13 comments
Labels
enhancement New feature or request

Comments

@aborruso
Copy link

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

@mbostock mbostock changed the title feature request: to allow the title channel to contain rich text or markup Allow the tip title channel to contain rich text or markup Jul 23, 2023
@mbostock mbostock added the enhancement New feature or request label Jul 23, 2023
@yurivish
Copy link
Contributor

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).

@CobusT
Copy link

CobusT commented Jul 25, 2023

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

https://observablehq.com/d/baeb8cbead1ed3d2

@hausdorff
Copy link

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.

@Fil
Copy link
Contributor

Fil commented Aug 7, 2023

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

@joe-bruce
Copy link

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!

@mbostock
Copy link
Member

@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

@mishatsvelik
Copy link

@mbostock
Copy link
Member

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

@aborruso
Copy link
Author

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?

@mbostock
Copy link
Member

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
Copy link
Member

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.

@Fil
Copy link
Contributor

Fil commented May 4, 2024

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

@bcrotty
Copy link

bcrotty commented May 21, 2024

For a simple customization, I would love to be able to attach the color swatch to a custom channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

9 participants