Basically, my question is that I have a dash app which follows the structure: Title, DCC Inputs, Text container, and Graph. However, I want my DCC Inputs, to update the page layout and depend upon each other. For a simplified code example, lets say I have an app layout as follows
app.layout = html.Div(children=[
html.H1("Title", style={
'text-align': 'center'
}),
dcc.Dropdown(
id='slct_type',
options=['type1', 'type2'],
placeholder="Select a type",
multi=False,
value='',
style={'width': '40%'}
),
html.Div(id='output_container', children=[], style={
'textAlign': 'center'
}),
html.Br(),
dcc.Graph(id='my_graph', figure={})
])
If I select type 1 in my first dcc dropdown, then I want the page to update to the following layout
app.layout = html.Div(children=[
html.H1("Title", style={
'text-align': 'center'
}),
dcc.Dropdown(
id='slct_type',
options=['type1', 'type2'],
placeholder="Select a type",
multi=False,
value='',
style={'width': '40%'}
),
dcc.Dropdown(
id='slct_number',
options=['1', '2'],
placeholder="Select a number",
multi=False,
value='',
style={'width': '40%'}
),
html.Div(id='output_container', children=[], style={
'textAlign': 'center'
}),
html.Br(),
dcc.Graph(id='my_graph', figure={})
])
Whereas is if I select type 2, I want this layout
app.layout = html.Div(children=[
html.H1("Title", style={
'text-align': 'center'
}),
dcc.Dropdown(
id='slct_type',
options=['type1', 'type2'],
placeholder="Select a type",
multi=False,
value='',
style={'width': '40%'}
),
dcc.Dropdown(
id='slct_colour',
options=['red', 'blue'],
placeholder="Select a colour",
multi=False,
value='',
style={'width': '40%'}
),
html.Div(id='output_container', children=[], style={
'textAlign': 'center'
}),
html.Br(),
dcc.Graph(id='my_graph', figure={})
])
The idea here is I always want my page format the same (title, followed by DCC input selection, followed by text output container, followed by graph) however which DCC inputs I want to put depend upon the first DCC input that the user selects. This will allow me to graph different datasets which take different parameters by first selecting the dataset type. Pls let me know if i can be more clear and thanks for any help