I am pretty new to dash and been struggling with a seemingly simple issue of adding a ‘Select All option’ to my dropdown.
Here is my code and would really appreciate if someone can help me out here . Thank you in advance
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()
all_1 = df['PRO Manager'].unique()
app.layout=html.Div([
html.H1("PRO Project Management dashboard"),
html.Div([
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= all, multi=True),
],className='six columns'),
@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 == 'Select 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