Closed joelostblom closed 2 days ago
Is this any help as a workaround: https://stackoverflow.com/questions/78066133/vega-lite-pie-chart-with-multi-selection-in-the-legend
Thanks for your suggestion @PBI-David ! I want to avoid a layered spec if possible so I opened https://github.com/vega/vega-lite/pull/9374 to enable another way of doing this in Vega-Lite.
Enhancement Description
If a legend filters the data when clicked, the legend will also be updated to remove all categories that are not selected. This has a few undesirable side effects, such as the color of the category changing after the click, not being able to select multiple legend entries, and having to double click to go back and select another entry (which is not clear unless you know this is how the interaction works). A current workaround for this is to specify a constant domain, but that only works if all the unique values are known ahead of time (which e.g. is not the case when creating a more general spec that will work with multiple data sources, such as in https://github.com/vega/altair/pull/3394).
Would it be possible to add an option so that legends are not filtered when the data is filtered, so that the legend entries correspond to the unique data values from the initial view only?
Here is an example Open the Chart in the Vega Editor
If I click to select "Japan", the color scheme changes to show "Japan" in blue instead of as in Orange in the original picture, and there is not way to shift click to add e.g. "USA" to the selection since the other legend entries are now filtered out
Here is an example of keeping all the entries in the legend even when the data is filtered https://plotly.com/python/plotly-express/#gallery