I’ve a dropdown options which populate the 1st value in the list when Dash is populated.
I created a Button such that when I click “Previous”, it will populate the (current value - 1) value in the dropdown value but I’m getting an error “TypeError Traceback (most recent call last)
TypeError: button_date_value() missing 2 required positional arguments: ‘available_options’ and ‘current’’”.
I’ve attached my code below. Please do let me know if I’m missing out something. Thank you!
app.layout = html.Div([
dcc.Dropdown(
id='dropdown',
options=options, value = options[0]["value"], style ={'width':'80%','display': 'inline-block'}
),
dcc.Dropdown(id = "dates",style ={'width':'80%','display': 'inline-block'}),
html.Button("Previous", id = "Previous", n_clicks = 0), html.Button("Next", id = "Next", n_clicks = 0),
dcc.Dropdown(id = "models", style ={'width':'80%','display': 'inline-block'}),
html.Hr(),
dcc.Graph(id="graph", style={"height": 800}),
html.Hr()
])
@app.callback(
dash.dependencies.Output("dates", "options"),
[dash.dependencies.Input("dropdown", "value")])
def set_dates_options(selected_node):
dates_model = [*models_changed[selected_node].keys()]
to_return = [{"label": i, "value": i} for i in dates_model]
return to_return
@app.callback(
dash.dependencies.Output("dates", "value"),
[dash.dependencies.Input("dates", "options")])
def set_dates_value(available_options):
return available_options[0]["value"]
@app.callback(
dash.dependencies.Output("dates", "value"),
[dash.dependencies.Input("Previous", "n_clicks"),
dash.dependencies.State("dates", "options"),
dash.dependencies.State("dates", "value")])
def button_date_value(clicks, available_options, current):
if clicks > 1:
return available_options[current - 1]["value"]