Skip to content

px.timeline() setting text to end column displays duration  #3019

Closed
@nicolaskruchten

Description

@nicolaskruchten

Broken off of #2934... Here the text will be the computed delta value because PX rewrites the data frame and reuses the column name Finish for x:

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="Alex"),
    dict(Task="Job C", Start='2009-02-20', Finish='2009-05-30', Resource="Max")
])
fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task", text="Finish")
fig.update_yaxes(autorange="reversed")
fig.show()

The current unfortunate workaround is to set text=df["Finish"]+"" which causes a separate column to be created in the internal data frame.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions