plotly / plotly/plotly.py

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

Open
#3,675 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3 regression
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the px.timeline entry point and compare its behavior with the create_gantt() figure factory, especially the group_tasks argument shown in the examples. Check the create_gantt() API documentation for the missing argument description. Done means repeated tasks can be rendered on separate y-axis lines with a defined ordering, and the relevant behavior is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.