-
-
Notifications
You must be signed in to change notification settings - Fork 668
fix: tooltip data "undefined" when using nearest hit testing #9707
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
base: main
Are you sure you want to change the base?
fix: tooltip data "undefined" when using nearest hit testing #9707
Conversation
Add failing test that demonstrates the bug introduced in v6.4.0 where discrete field values that are undefined get converted to the string "undefined" instead of remaining as undefined or null. The bug is in the addLineBreaksToTooltip function which uses ""+datum["field"] as a fallback, causing undefined to be stringified. This test will fail until the bug is fixed.
|
@michaelwallabi Thanks for finding this bug and creating such comprehensive test cases! As the author of the PR that seems to have introduced the bug I feel responsible and am eager to look into this together. Although it seems to fix the problem I'm not quite sure if returning As you point out, the problem (only) seems to occur when using hover parameters. I think this is because the signal for the voronoi layer should reference Do you agree? If so, any ideas for an elegant solution? |
|
Thanks for responding @basbroek. Agree, the fix here is just papering over a deeper issue. Appreicate the pointers, will take a look and see if I can come up with something better. |
|
Found a better/simpler fix. Can't say I understand the difference between My understanding is that the key nuance here is that when using "nearest" tooltips a fully transparent voronoi diagram is used as a hit target for the actual marks. It's adding this voronoi layer that requires using |
Custom tooltip handlers receive string "undefined" instead of data values in v6.4.0
Description
In vega-lite 6.4.0, custom tooltip handlers (set via
view.tooltip()) receive objects where some field values are the string"undefined"instead of the actual data values. This regression was introduced as part of: #9678.This PR includes a potential fix and some tests. This is my first time digging in to vega-lite details so very possible this isn't the right fix.
Repro
tooltip-no-repro-6.3.1.html
tooltip-repro-6.4.0.html
Expected Behavior
The tooltip handler should receive an object with actual data values:
Actual Behavior (v6.4.0)
The tooltip handler receives an object where some values are the string
"undefined":Key Details
The issue occurs specifically with:
view.tooltip()The default Vega tooltip rendering appears to work correctly, but custom handlers receive corrupted data.