hey @MrEngineer.
If you tag me using @AIMPED I’ll see your posts earlier. Concerning the choices, are you referring to my example?
Here an extended example:
import dash
from dash import dcc, html, Input, Output
import numpy as np
import plotly.graph_objects as go
def create_figure():
return go.Figure(
go.Scatter(
x=np.arange(10),
y=np.random.randint(1, 10, size=10),
mode='markers+lines'
)
)
app = dash.Dash(
__name__,
external_stylesheets=[
"https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css",
]
)
app.layout = html.Div(
className='row',
children=[
html.Div(
className='col-3',
children=[
html.Div(
[
dcc.Dropdown(
id='main_dropdown',
options=[1, 2, 3],
multi=False,
value=1
)
]
),
html.Div(
id='additional_content',
children=[
dcc.Dropdown(
id='additional_dropdown_1',
options=[4, 5],
multi=False,
),
dcc.Dropdown(
id='additional_dropdown_2',
options=[6, 7],
multi=False,
)
]
),
html.Button(id='btn', children='dummy')
]
),
html.Div(
className='col-8',
children=[
dcc.Graph(id='graph', figure=create_figure())
]
)
]
)
@app.callback(
Output('additional_content', 'style'),
Output('graph', 'figure'),
Input('main_dropdown', 'value'),
)
def show_hide(selection):
show_optional_components = {'display': 'initial'}
hide_optional_components = {'display': 'none'}
default_config = {'display': 'none'}
if selection == 1:
return hide_optional_components, create_figure()
elif selection == 2:
return show_optional_components, create_figure()
elif selection == 3:
return show_optional_components, create_figure()
else:
return default_config, create_figure()
if __name__ == '__main__':
app.run(debug=True, port=8070)