-
Notifications
You must be signed in to change notification settings - Fork 799
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
Custom order of points drawing a line #1096
Comments
The |
You can derive a new field and sort by that field e.g., something like:
|
If you think this custom order should be supported, please file an issue in Vega-Lite repo. |
Thanks folks. Solved. |
can someone explain how this is solved clearly with example code. I also want to sort the stacked bars in a custom order. Lower stack say is 'Leave', Middle stack is 'Roster', Upper stack is 'OT' for Work Types. just ascending and descending for sort order doesn't cut it. |
Currently you can control the stack order using an import altair as alt
import pandas as pd
df = pd.DataFrame({
'label': ['Leave', 'OT', 'Roster'],
'hours': [5, 6, 7]
})
alt.Chart(df).transform_calculate(
order="{'Leave': 0, 'Roster': 1, 'OT': 2}[datum.label]"
).mark_bar().encode(
x='hours',
color=alt.Color('label', sort=['Leave', 'Roster', 'OT']),
order='order:Q'
) When vega/vega-lite#1734 is addressed, this will be easier. |
Hi there folks.
@jakevdp I'm happy I found your comment here #689
Right now I'm having trouble drawing a line exactly because of the ordering issue.
My problem is that I have to specify the ordering by providing the values, more or less like this:
but I'm getting:
Is there any workaround for this?
The text was updated successfully, but these errors were encountered: