✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Plotly GANTT chart sorting? - Dash

It is possible to define the sort order of grouped tasks on the gantt chart?

Every time I reload the chart with new data it seems to randomly choose an order to list the groups down the y axis…

fig = ff.create_gantt(df, colors=colors, index_col='Resource', bar_width=.5,
                      show_colorbar=False, showgrid_x=False, showgrid_y=False, group_tasks=True)

Couldn’t find anything in documentation, would have to think there is a way to do this though…

The order is by colour. E.g. I am using the following for something and it orders from A to F.

colors = dict(A = ‘rgb( 0, 0, 0)’,
B = ‘rgb( 0, 0, 150)’,
C = ‘rgb( 0, 0, 250)’,
D = ‘rgb( 0, 100, 250)’,
E = ‘rgb( 0, 200, 0)’,
F = ‘rgb(250, 0, 0)’)

Unfortunately this does’t seem to always be true:

colors = {4: white, 2: light_blue, 1: dark_blue, 3: teal}

fig = ff.create_gantt(df, colors=colors, index_col='Resource', bar_width=.5,
                      show_colorbar=False, showgrid_x=False, showgrid_y=False, group_tasks=True)

The same code sometimes when fed different data returns both of these variationsScreen Shot 2020-07-14 at 11.52.44 AM Screen Shot 2020-07-14 at 11.52.30 AM