-
Notifications
You must be signed in to change notification settings - Fork 623
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
Tooltips for selected mark are not evaluated #6522
Comments
Interestingly, the behavior seem to be different for {
"$schema": "https://vega.github.io/schema/vega-lite/v4.11.0.json",
"description": "Drag out a rectangular brush to highlight points.",
"data": {"url": "data/cars.json"},
"selection": {
"brush": {
"type": "interval",
"init": {"x": [55, 160], "y": [13, 37]}
}
},
"mark": {
"type": "point",
"tooltip": { "content": "data" }
},
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative"},
"y": {"field": "Miles_per_Gallon", "type": "quantitative"},
"color": {
"condition": {"selection": "brush", "field": "Cylinders", "type": "ordinal"},
"value": "grey"
}
}
} |
It looks like the selection state of the mark isn't what prevents the tooltip from displaying, but rather whether the mouse is inside the brushed selection area or not. In this case the mouse cursor (not visible in the screenshot) is inside the brush rectangle, and the tooltip doesn't work: But in this case the mouse cursor is over the selected mark, but outside the brush rectangle: So it appears that it is the selection indicator that is messing up the tooltip, rather than the selection state of the mark itself. |
It turns out that this is simply the behavior of a mark that has empty data. E.g., this mark will show the literal "content: encoding" as the tooltip: {
"$schema": "https://vega.github.io/schema/vega-lite/v4.11.0.json",
"data": {"values": [{}]},
"mark": "rect",
"config": {
"mark": {
"tooltip": { "content": "encoding" }
}
}
} So the problem is probably just that the brush selection area is itself a mark with empty data. I think the best solution would be to just ignore the tooltip directive for marks with no associated data, thus letting the child mark tooltip handler take over. |
For now I'll drop To ignore the tooltip directive for marks with no associated data, we need to add such support in Vega first, so I'll move this issue to Vega. |
@kanitw Can you please describe in greater detail what you are suggesting Vega should do? Thanks! |
I took a closer look. The tooltip tissue here is that indeed the brush is realized as its own mark that is drawn on top of the data-representative marks. Interactive events such as mouseover are "consumed" by the brush and never triggered for underlying bars/points. I don't think there is much we can do about this, as the brush foreground needs to be interactive to receive events for resizing and repositioning. That said, the mark-level As for the tooltip trigger on the brush, I believe VL should simply refrain from adding tooltip encodings to "meta-marks" such as brushes. |
Can you transfer this issue back to the vega-lite repo so we can continue to track it there? |
Re-opening and transferring to Vega-Lite per @marcprux's request. |
Though a bit niche, one possible "mechanism": |
Dear all, I think I am facing the same scenario and need some help.. I have been reading through the docs, issues and SO. This seems to be the most relevant discussion, but I need some more guidance on how to work around.. below are some ways I attempted but failed (maybe due to lack of understanding):
This is the trimmed chart |
It turns out the hidden tooltips can be manually turned on simply by setting this in
|
This comes from the "Interactive Average" sample with tooltips enabled in the config:
The tooltips over unselected marks show the correct values for the
tooltip
field, but any selected marks will show the unprocessed value of the tooltip config setting, regardless of the value (e.g.,true
,false
,{ "content": "data" }
).If, instead,
tooltip
is specified in themark
def rather than in theconfig
, then the tooltip isn't shown at all for any marks that are selected (but they are still displayed properly for unselected marks). I.e.:FTR, I've noticed this behavior with vegaEmbed when passing
"tooltip": true
in theoptions.config
parameter (in other to enable default tooltips), but I don't know if that is a bug withvega-embed
,vega-lite
, orvega
.The text was updated successfully, but these errors were encountered: