-
Notifications
You must be signed in to change notification settings - Fork 629
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
Facet Cannot Be Correctly Sorted #8675
Comments
Possibly related to #5937 as this looks like a sort problem when gaps are present. |
I think I found the same thing. Using altair: import altair as alt
from vega_datasets import data
source = data.cars()
chart = alt.Chart(source).mark_point().encode(
x="Horsepower",
y="Miles_per_Gallon",
color="Origin",
).facet(
row="Cylinders",
column=alt.Column("Origin", sort=["USA", "Europe", "Japan"]),
)
chart.to_json() Generates the following vega lite spec, where data points are placed in the incorrect column. If you remove the sort, then the points are placed in the correct column. |
Any news on this Vega Team? Still a bug as you can see here. The only solution I have found is to push in fake data into the data set so every row and column has data. But this shouldn't be necessary.
|
This might be the same issue: A cut back version, blank spaces lead to wrong chart alignment when sorted. |
padding with zeros fixes |
Padding what with zeros fixes what? Do you mean that the incorrect assignment in the facets is fixed when you add entries for the missing combinations? |
Yes. In fact i just add a zero-ed entry for every cell and dont bother to work out the missing. |
I think the fix might be: add a column_index like the row_index in the compiled vega above:
the column_index can then be used in the cell function:
|
That's good idea. Do you nee a good way to do this without knowing the values? Note that Vega-Lite doesn't see the data so we need to generate generic Vega that doesn't depend on specific values. |
I realised we don't have a VL example of the Vega calendar so I tried to create one to submit as a PR. Everything is working fine apart from years with incomplete months cannot be sorted. Observe that Jan, Feb, Mar, Apr for 2020 are all pushed to the end of the chart and listed under Sep, Oct, Nov & Dec. I have tried various documented sort operations but this seems like a bug.
Editor link
The text was updated successfully, but these errors were encountered: