I am pretty new to Plotly/Dash and currently struggling to add a 'Select All' option for my dropdown especially on the callback. Please help, been stuck on this for a some time.
app = dash.Dash(__name__)
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
all = df.Pillar.unique()
options=[{'label':x , 'value':x} for x in all]
options.append({'label': 'Select All', 'value': "all"})
app.layout=html.Div([
html.H1("PRO Project Management dashboard"),
html.Div([
html.P('Pillar'),
dcc.Dropdown(id='pillar-choice', options=[{'label':x , 'value':x} for x in all] + [{'label':'Select All' , 'value':'all'}] , value= 'for', multi=True),
]),
html.Div([
dcc.Graph(id='graph1', style={'display':'inline-block', 'width' :'33%'})
]),
])
@app.callback(
Output(component_id='graph1', component_property='figure'),
Input(component_id='pillar-choice', component_property='value')
)
def update_graph1(value_pillar):
if value_pillar == 'all':
dff = df
else:
dff = df[df.Pillar.isin([value_pillar])]
fig = px.pie(data_frame=dff, names='Pillar', values='Project No', title='Number of Projects by Pillars')
return fig
if __name__=='__main__':
app.run_server()