Gantt Chart legend displaying in the wrong order

Hi,
I am trying to make a Gantt chart using plotly. I am however having two problems.

  1. The legend order is wrong and I cannot figure why
  2. How can I have a task that has multiple start and stop packages.

The code is below, many thanks

import plotly.figure_factory as ff
import plotly.graph_objs as go
import plotly.express as px
import plotly

df = [dict(Task="Task 6.5", Start='2023-12-01', Finish='2024-03-01', Workpackage='WP6'),
      dict(Task="Task 6.4", Start='2023-05-01', Finish='2023-12-01', Workpackage='WP6'),
      dict(Task="Task 6.3", Start='2022-12-01', Finish='2023-08-01', Workpackage='WP6'),
      dict(Task="Task 6.2", Start='2022-12-01', Finish='2023-04-01', Workpackage='WP6'),
      dict(Task="Task 6.1", Start='2022-09-01', Finish='2022-12-01', Workpackage='WP6'),
      dict(Task="Task 5.4", Start='2023-05-01', Finish='2023-11-01', Workpackage='WP5'),
      dict(Task="Task 5.3", Start='2023-05-01', Finish='2023-10-01', Workpackage='WP5'),
      dict(Task="Task 5.2", Start='2022-10-01', Finish='2023-05-01', Workpackage='WP5'),
      dict(Task="Task 5.1", Start='2022-05-01', Finish='2022-10-01', Workpackage='WP5'),
      dict(Task="Task 4.3", Start='2023-06-01', Finish='2023-09-01', Workpackage='WP4'),
      dict(Task="Task 4.2", Start='2022-11-01', Finish='2023-08-01', Workpackage='WP4'),
      dict(Task="Task 4.1", Start='2022-03-01', Finish='2022-11-01', Workpackage='WP4'),
      dict(Task="Task 3.3", Start='2023-04-01', Finish='2023-08-01', Workpackage='WP3'),
      dict(Task="Task 3.2", Start='2022-04-01', Finish='2023-04-01', Workpackage='WP3'),
      dict(Task="Task 3.1", Start='2021-12-01', Finish='2022-04-01', Workpackage='WP3'),
      dict(Task="Task 2.5", Start='2022-11-01', Finish='2023-04-01', Workpackage='WP2'),
      dict(Task="Task 2.4", Start='2022-05-01', Finish='2022-11-01', Workpackage='WP2'),
      dict(Task="Task 2.3", Start='2021-06-01', Finish='2022-06-01', Workpackage='WP2'),
      dict(Task="Task 2.2", Start='2021-06-01', Finish='2021-11-01', Workpackage='WP2'),
      dict(Task="Task 2.1", Start='2021-06-01', Finish='2021-06-01', Workpackage='WP2'),
      dict(Task="Task 1.5", Start='2021-03-01', Finish='2024-03-01', Workpackage='WP1'),
      dict(Task="Task 1.4", Start='2021-03-01', Finish='2021-07-01', Workpackage='WP1'),
      dict(Task="Task 1.3", Start='2024-03-01', Finish='2021-06-01', Workpackage='WP1'),
      dict(Task="Task 1.2", Start='2021-03-01', Finish='2024-03-01', Workpackage='WP1'),
      dict(Task="Task 1.1", Start='2021-03-01', Finish='2024-03-01', Workpackage='WP1'),]

colors_graph = dict(WP6='#1f77b4', WP5='#ff7f0e', WP4='#2ca02c', WP3='#d62728', WP2='#9467bd', WP1='#8c564b')


fig = ff.create_gantt(df, colors=colors_graph, index_col='Workpackage', show_colorbar=True, bar_width = 0.3, height = 600, group_tasks=False, showgrid_x=True, showgrid_y=True)

fig.show()

Which produced the following graph

I’m having the same issue with the legend order. I want to sort mine alphabetically.

You can use traceorder to reverse orders of input, and I think there are a couple of other settings, but currently I can’t find a way to sort alphabetically.

fig['layout'].update(legend=dict(traceorder='reversed'))

Waiting for the same functionality.