-
Notifications
You must be signed in to change notification settings - Fork 621
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
Filtering out zero/null values in tooltip and sort the tooltip by field values #9152
Filtering out zero/null values in tooltip and sort the tooltip by field values #9152
Comments
Opened an issue in vega-tooltip: vega/vega-tooltip#819 |
moving ticket to vega-tooltip repo since it's vega-tooltip specific feature. |
@kanitw Thanks! I've created a PR in another ticket there vega/vega-tooltip#820. Appreciate any suggestions and comments:) |
@kanitw To add parameters to control this, we need to modify vega-lite or vega, no? |
@kanitw I'm not sure this is tooltip-specific since Vega tooltip is only one specific implementation of a tooltip. I think hiding/sorting can be something useful for Vega-Lite itself. Note that you can already sort tooltip fields by manually providing the list of fields. Filter for tooltip at mark levelI think we can add sorting/filtering to I think it makes sense to add
and filter predicates (using https://vega.github.io/vega-lite/docs/predicate.html)
For filtering/sorting with a tooltip encodingFiltering with expressions as in #9148 looks reasonable. Sorting a list of fields is a bit trickier since the encoding defs passed to |
@domoritz I agree. I've pushed some new commits (making 'sort' to be a new parameter as part of 'encoding', which is a higher level) in #9148 with more details in the description. Appreciate it if you could take a look. Yeah sorting is trickier. From my understanding, before the encoding defs are passed to vega-tooltip they remain to be some vega expressions, and their values cannot be determined. I really spent some time investigating whether there's a intermediate step to convert these expressions to actual values. But it seems that the values will only be evaluated when the mouse hover event is triggered, that's why I modify the things in vega-tooltip as well because we can only sort the data from there. Correct me if I'm wrong, and if you have a way to handle everything within vega-lite & vega, that'd be great:) |
@domoritz Yes. I observed that the order of the tooltip is aligned with how I provide it in the tooltip array. But this is a manual way and can only set one global order for all the tooltips (with different x-axis values). At the end of the day we want to sort the tooltip always by the descending order of the values instead of a manually specified order of the keys. |
Note that Vega tooltip is only one example implementation of a tooltip for Vega. Therefore I think we should try to do as much as possible in Vega/Vega-Lite. As you develop your code, test it without Vega tooltip to see what the default tooltips (using HTML Can you summarize the proposed API changes here? It'll be easier to discuss it compared to the pull request. I know it's a bit more work but I would appreciate it. Thanks! |
@domoritz Thanks for the response!
Parameter signatures: Sort - added as a parameter for encoding:
To make the new parameters robust, both filter & sort_tooltip can only be some enum values. sort_tooltip.value: 'ascending' or 'descending' only: Please see #9148 for more details. Thanks! |
@kanitw Thanks for the reply! |
@domoritz Made a PR to support default tooltips: vega/vega#3816. Now the default tooltips (you can see I've disabled vega-tooltip in the editor) are filtered & sorted with the exactly same specification as above: Let me know if there's anything else we should do. Thanks! |
@domoritz @kanitw Happy new year folks! I hope you have a wonderful break. Could we move this forward a little bit? I believe this will be a useful feature for the whole community since I've seen such requests even as early as 3 years ago. So, it'd be good if you could review this so that I can make further changes. Thanks! |
I'll put it on my queue. Thanks for the ping. |
@domoritz Hi Dominik, I hope you are doing well. Kindly check in to see if you get any chance to take a look at this. Thanks! |
Uhh, yeah, it's in my queue. I'm going on vacation tomorrow for a few weeks but let me bump it up for after I return. |
@domoritz Appreciate that, have a wonderful vacation! |
I'd like to add a feature to hide/filter out zero/null values in the tooltip, and potentially sort the tooltip by the value of each field/column. Here's an example:
Basically I want to hide
type3
andtype5
in the tooltip, and sort the remaining by descending order of Value.Since I'm not familiar with altair/vega libraries, so this might not be the best approach, but my thought is to add a new parameter/condition in altair and passing this to the tooltip object, so that when the frontend receives this signal, it will hide the values I don't want to see in the tooltip and possibly sort the values.
I found 2 places that can be modified:
Any guidance and suggestions are welcome. Thanks! cc @joelostblom @jakevdp as well as core vega-lite developers @kanitw @domoritz @arvind @jheer
The text was updated successfully, but these errors were encountered: