Hello @farispriadi,
This is Great and I will certainly study and learn much from this code.
As a newbie , my actual application is for work and Is there a way I can share with you directly my dilemma for privacy??.
My work plot has mulitple timeline plots for various task associated with each product as well certain Milestones which I used (add.trace)Timeline &Scatter plots to accomplish ?
Meanwhile for others to learn along with me, I will attempt to describe further keeping this example in mind.
Below is what I came up with from trying different codes snippets( if theres a source for a beginner to understand the updatemenus / buttons / args please advise
As shown below. This however DOES NOT work as you indicated and YES the layout is broken once I click on the dropdown. I also did not figure out how to get back to label = "All " yet.
ALSO when I change the color = “Task” to color = “Customer” - the Legend appears and provides the EXACT functionality I am looking for but AGAIN for my end application the TASK in the Legend is what I need.
OK here’s what I’m thinking:
1. When I click on the Customer, can I then filter the dataframe and then pass the new args to the timeline plot to then regenerate the plot (same way as the legend would accomplish. ??
AGAIN thank you for the response but I’m still in need of a way of doing this WITHOUT DASH.
import plotly.express as px
import pandas as pd
import plotly.offline as pyo
file_path = “/Users/dabideena/Documents/Python Programs/SampleFilter.xlsx”
df = pd.read_excel(file_path)
fig = px.timeline(df, x_start=“Start”, x_end=“End”, y=“Product”, color=“Task”)
fig.update_yaxes(autorange=“reversed”)
fig.update_layout(
updatemenus=[
dict(
type=“dropdown”,
showactive=True,
buttons=list(
[
dict(
label=cust,
method="update",
args=[
{
"visible": [
True if c == cust else False for c in df["Customer"]
]
}
],
)
for cust in df["Customer"].unique()
]
),
)
]
)
fig.show()