-
Notifications
You must be signed in to change notification settings - Fork 796
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
Tooltip is not working with condition #3196
Comments
I'm not sure why this fails but you should be able to achieve the same thing by calculating a new field using |
@binste Thanks, that's good to know. Actually, I want to filter out zero/nan values in the tooltip and possibly sort the tooltip by values: vega/vega-lite#9152, so I'm not sure whether |
I never tried setting a condition on a tooltip but I'd expect that it would still show an entry in the tooltip for that field but you can choose what value is shown but that's just a guess. I'm also curious to see if someone knows more in the Vega-Lite issue you opened :) |
@binste Thanks. From your knowledge, would this be possible by modifying the altair side only? I'm trying to understand how altair passes these tooltip specification to the frontend, for now I only see it's a list of
|
Altair produces Vega-Lite specifications, see Altair Internals. These specifications are often passed to vega-embed to be rendered in a frontend such as when you display an Altair chart in a Jupyter notebook. This means that you can't modify Altair to change the rendering as Altair is not involved in the rendering process at all. Hence, what you are looking for is only possible in Altair if it is possible in Vega-Lite. I hope this helps. |
@binste This is super helpful, thanks! |
Sorry I can't help you with that as I'm not very familiar with developing Vega-Lite. But using the editor in the way you described it is the best way I'm aware of. |
It seems like although the tooltip encoding supports multiple fields there is no way to express this in a condition. This would need to be added in VL and the relevant issue tracking it is now vega/vega-lite#8750. I'm closing this as there is no action to take in altair. The functionality will be available after it is implemented in VL. |
Error message:
SchemaValidationError: Tooltip has no parameter named 'condition' Existing parameter names are: shorthand bin format title aggregate condition formatType type bandPosition field timeUnit See the help for Tooltip to read the full description of these parameters
Repro:
selection_chart.encoding.tooltip[0].condition = alt.condition(alt.datum.type1 > 0, 'type1', alt.value(''))
or
"tooltip": [alt.Tooltip('Date'), alt.Tooltip('type1:Q', condition=alt.condition(alt.datum.type1 > 0, 'type1', alt.value('')))]
The text was updated successfully, but these errors were encountered: