-
Notifications
You must be signed in to change notification settings - Fork 611
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
fix: facet missing data bug fix #9434
base: main
Are you sure you want to change the base?
Conversation
Thanks for the pull request. Please make sure that the test pass and if you can that the linting also passes. |
@domoritz As I mentioned in the pull request there is one failing test, namely vega-lite/test/compile/facet.test.ts Lines 490 to 518 in d5e98a8
Since my suggested workaround changes the facet grouping as described above, it is clear that this test should fail in vega-lite/test/compile/facet.test.ts Lines 507 to 512 in d5e98a8
I have now updated the testing file in my fork by simply changing the above to vega-lite/test/compile/facet.test.ts Lines 507 to 509 in 6b207f7
in order to match the updated grouping logic. Regarding the linting, it already seems to pass? |
@domoritz Is this PR looking good to you? Fixing this bug in VL would help us understand if there is anything additional going wrong in Altair for vega/altair#3588. |
PR Description
This is a suggested fix for #5937 and potentially also #8675 and vega/altair#3588 and vega/altair#3481
I included two examples demonstrating the bug. For instance the spec
results in
while it should look like this:
I think the bug is due to the following. The key part of the compiled Vega spec looks like
As far as I understand this performs a
groupby
according to cylinders and origin, and then for each group determinesmean_Horsepower_by_Cylinders
andcolumn_Origin_sort_index
used for sorting by aggregating over the data points in the facet and taking the max (it does not matter as the column sort index is the same for all points in the facet anyways, so one could also take e.g. the min). The problem arises when a facet is empty as then the aggregation cannot determine the valid sort index. As a result, some facets are not assigned a sort-index, see this screenshot from the Vega Editor -> Data Viewer -> cell:For some reason the cells with missing sort-index result in some data points being placed in the wrong facet (not exactly sure what goes wrong here exactly).
My bug fix suggestion simply replaces the above spec by
i.e. it directly groups by the sort index, avoiding cells without assigned indices. This is simpler than the original code. For all examples I looked at, it worked. However, maybe I overlook some unintended side effects.
Out of all the tests a single test in
test/compile/facet.test.ts
fails, namely line 507. As far as I can see this test directly checks the section of the compiled Vega spec outlined above, so in some sense I would expect it to fail.Checklist
yarn test
runs successfully