-
Notifications
You must be signed in to change notification settings - Fork 45
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
Support coloring certain fields #215
Comments
Yeah, that would be nice. Vega-Lite could just generate tooltips with HTML and the tooltip library could render them. A better solution would be to pass a color separately somehow. I don't have a good idea yet, though. |
From chatting with my colleagues at Apple and @kristw, multi-series line is actually quite common and there is a need for a good tooltip for it. To follow up, there should be a way to pass some metadata for each mark group to the tooltipHandler. Then vega-tooltip can then define its own metadata format. A few options for how to pass this to the plugin:
For example, if the tooltip is The tooltip can then read
I think 1) is cleaner as we don't have to modify Vega tooltip handling / default handler. Perhaps the only thing is to make Any thoughts? cc: @jheer @domoritz Note that I'm not fixated on how the parameter object (e.g., |
I'm okay with either of those two options. Wouldn't it be easier and more flexible, though, if you could pass some html string to label keys instead? I'm worried that we would gradually add more and more things to the params. |
Sounds good, i was thinking about html/svg string when i walked to dinner too. There are some benefits for having some language consistency but it seems hard to define the scope so it’s probably better to just leverage HTML string. |
If we want to support HTML / SVG string by default though, then we should modify how we sanitize the tooltip key. (Right now HTML isn't allowed at all. Perhaps, we can allow a subset of it, but ban JS instead for security?) |
Yeah, we would need to make some changes. I think it would be nice to support an object to map keys to labels. It's a bit add to have to put large strings into keys. |
Actually, thinking about generality of our language, it might be better to define a syntax here. |
I agree as long as we scoped the extension. |
I think we can structure this parameter object like other guides: Suppose we use the method 1. above (
This would be quite natural in Vega-Lite:
or for manually specified tooltip channel: encoding: {
...
tooltip: [
{field: 'a', type: ..., tooltip: {symbolType: 'circle', symbolColor: 'red', titleColor: 'red'}
...
]
} |
These tooltips in https://observablehq.com/@benoldenburg/mta-daily-ridership-recovery by @benoldenburg are beautiful. I think it would be awesome if we could try to enable tooltips like that in Vega. |
need this feature a lot |
Yup this would be very nice ! Any idea of the progression of it so far ? |
Not from my side. I'm looking for someone who would be willing to take on this issue. I think it shouldn't be too difficult. We need to add a field to the object that Vega-Lite generates and then we need to read it out when we generate the tooltip HTML. |
Well sadly I don't have the skills for it ... maybe @kanitw who first had the idea ? |
Glad to have found this is being discussed. I think it makes a lot of sense to handle tooltips the same way a symbol legend is handled so that it can accept the same channels: color, opacity, size, and shape. Example below showing the symbols on the left side of the tooltip labels where applicable. I can't share this specific example but here is one I have been mirroring the majority of the spec with using a public dataset: |
FWIW, I was able to do part of this with pure CSS by targeting the
Where What I would really like is just the option of adding a |
This is especially useful for multi-series line chart (e.g., in
vega/vega-lite#4293).
Here readers can benefit if the
temp_max
andtemp_min
have some colors.For example, something like:
(The circles are manually drawn for demonstration)
The text was updated successfully, but these errors were encountered: