Skip to content

Missing functionality in px.timeline against create_gantt() figure factory #3675

Open
@saimonduquet

Description

@saimonduquet

create_gantt() figure factory is deprecated in favor of px.timeline, but create_gantt() has the feature (argument) group_tasks that is not present with px.timeline.
An additional issue is that the group_task argument is not explained in the create_gantt() documentation check here.

For example, the code:

import plotly.express as px
import pandas as pd

df = pd.DataFrame([
    dict(Task="Job A", Start='2009-01-01', Finish='2009-02-28', Resource='Alex'),
    dict(Task="Job B", Start='2009-03-05', Finish='2009-04-15', Resource='Max'),
    dict(Task="Job C", Start='2009-02-20', Finish='2009-05-30', Resource='Max'),
    dict(Task="Job A", Start='2009-03-02', Finish='2009-05-30', Resource='Alex')
])

fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task", color = "Resource")
fig.update_yaxes(autorange="reversed") # otherwise tasks are listed from the bottom up
fig.show()

Produces:
enter image description here

And I would like to have each tasks in the input data frame into its own line in the y-axis, even for repeating tasks:
enter image description here

We can obtain this using create_gantt() like:

from plotly.figure_factory import create_gantt

fig = create_gantt(df, index_col='Resource', 
                      showgrid_x=True, showgrid_y=True,
                      show_colorbar=True,
                      group_tasks=False
                      )
fig.update_yaxes(autorange="reversed")
fig.show()

Obtaining:
2022-04-11 19_51_14-127 0 0 1_1586

The order follows the order in the df which I found a correct behavior, but an extra input to define the order in create_gantt() would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething brokenregressionthis used to work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions