I am working with a dataset with 4 columns
Date | Category | Sub-category | Expenditure |
---|
I want to create a dashboard which shows expense vs date for select category and its subcategories. I get it the following way
cats = df.Category.unique()
tags={key: [] for key in cats}
for cat in cats:
tags[cat] = df[df.Category==cat].Subcat.unique()
@callback(Output(graph,"figure"),Input(dropdown,"value"))
def update_bar_chart(cat):
mask = df['Category']==cat
fig = px.bar(df[mask].groupby(df.Date)['Expense amount'].sum())
for i, tag in enumerate(tags[cat]):
mask = df['Subcat']==tag
fig.add_traces(list(px.scatter(df[mask].groupby(df.Date)['Expense amount'].sum()).select_traces()))
return fig
However they all appear in the same color. How can I set line color for each trace?