I am working on making a dashboard for an hr dataset and am trying to have one the bar charts be able to drill down on the column that the user clicks on. Is there any way to do this in Dash?
Here is what my current graph looks like.
I am thinking that I might have to embed a link through a click element on each column of the bar chart in order to make it “drill down” into each columns element but I am not sure whether there is an easier way to do this or not.
Here is my current code that I used to make the graph inside my dashboard: @app.callback(Output(‘tot_hours’,‘figure’),
[Input(‘month_slider’,‘value’)])
def tot_hors(month_slider):
data=[
go.Bar(
y=df.loc[df[‘ed_code’].isin([‘E02’,‘E04’,‘E03’,‘E01’,‘E05’]),‘hours’].groupby(df[‘month’]).sum(),
x=df[‘month2’].unique(),
name=‘Worked’,
text=df.loc[df[‘ed_code’].isin([‘E02’,‘E04’,‘E03’,‘E01’,‘E05’]),‘hours’].groupby(df[‘month’]).sum(),
marker=dict(color=’#42A5B3’),
showlegend=True
),
go.Bar(
y=df.loc[df[‘ed_code’].isin([‘E20’,‘E12’,‘E11’,‘E14’,‘E13’]),‘hours’].groupby(df[‘month’]).sum(),
x=df[‘month2’].unique(),
name=‘Sick’,
text=df.loc[df[‘ed_code’].isin([‘E20’,‘E12’,‘E11’,‘E14’,‘E13’]),‘hours’].groupby(df[‘month’]).sum(),
marker=dict(color=’#D15A86’),
showlegend=True
)
]
layout= go.Layout(
title='Total Hours',
legend=dict(x=-.1,y=1.1),
hovermode='closest',
barmode='stack'
)
figure = {'data':data,'layout':layout}
return figure
Thanks in advance!