Hi,
How to create multiple input which output can be returned when only one of the input is fulfill?
For example, I had 2 dropdown list / input in for the same graph, Date
and Product
.
If one of the dropdown is selected, eg, Date
, then all the product under the selected date will be shown in the graph.
If 2 of the dropdown are selected, eg, Date
and Product
, then only the specific product in the selected date shown in the graph.
You can use 2 Input for one Output. For Example:
@app.callback(Output('figure_1','figure'),
[Input('dates','value'),
Input('product','value')])
def update_graph(date, product):
if date != [] and product != []:
dff = df[df['dates'] == dates]
dff_1 = dff[dff['products'] == products]
elif date == [] and product != []:
dff_1 = df[df['products'] == products]
elif date != [] and product == []:
dff_1 = df[df['dates'] == dates]
else:
dff_1 = df.copy
fig = px.Bar(dff_1,...)
return fig