@chriddyp
I am a bit new to dash. Please help me out
I want to dynamically add a dropdown in my dashboard based on the requirements. For eg. if I choose just 3 columns from a dataframe for plotting, I can plot all of it without dropdown selections. However when there are more than 3 features, its not possible to represent all of it in a single plot, so I want to dynamically add dropdowns for all those extra columns(categorical). And based on the selection, it will show the plot.
Create a html.Div(children=[], id='div_for_dropdown') in your layout. This Div will be empty be default because the children property is an empty list.
Create a callback function that will populate your Div with a dropdown based on defined conditions.
@app.callback(
Output('div_for_dropdown', 'children'),
[Input(...),
Input(...)])
def generate_dropdown(input_1, input_2):
if condition_for_generating_dropdown:
children = [
dcc.Dropdown(...)
]
else:
children = []
return children