Repository navigation
Persisting Tooltips by clicking on datapoints #9752
Replies: 1 comment
|
Not with the tooltip channel: Vega only calls the tooltip handler on {
"data": {"url": "data/cars.json"},
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative"},
"y": {"field": "Miles_per_Gallon", "type": "quantitative"}
},
"layer": [
{
"params": [{"name": "pinned", "select": {"type": "point", "on": "click", "toggle": "true"}}],
"mark": "point",
"encoding": {
"color": {"condition": {"param": "pinned", "empty": false, "value": "red"}, "value": "steelblue"},
"tooltip": [{"field": "Name"}, {"field": "Horsepower"}, {"field": "Miles_per_Gallon"}]
}
},
{
"transform": [
{"filter": {"param": "pinned", "empty": false}},
{"calculate": "[datum.Name, 'Horsepower: ' + datum.Horsepower, 'MPG: ' + datum.Miles_per_Gallon]", "as": "label"}
],
"mark": {"type": "text", "align": "left", "baseline": "middle", "dx": 8, "dy": -13},
"encoding": {"text": {"field": "label"}}
}
]
}Each click on a point adds or removes its label, clicking a label removes it too, and double-clicking a point clears them all (double-clicking empty space doesn't). The array from |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I am trying to annotate my chart by persisting tooltips even after the cursor that triggered the tooltip, moves away. I am trying to achieve a
click to persisttooltip experience, so that multiple tooltips could be presented in the same chart by clicking on specific points of interests.I am aware that this could also be done by annotations with a text layer, but I am curious to find out if there is a way to persist the tooltips even when the hovering event is not captured.
Expected Experience:
This is an edited image and is what I am trying to achieve in my chart.
Vega Editor: Link
All reactions