I am trying to create a dropdown menu with dash core component in python. The dropdown menu should have dynamic options, and the selections of the dropdown menu would affect other callback functions.
The problem with my code isn't the logic within the functions. The function generating the options within the dropdown menu returns the correct stuff.
I looked at other answers on other sites that said to define the dropdown menu with dynamic options like this
dcc.Dropdown( id="dropdown_id",multi=True,placeholder="Select an Option", ),
While the official plotly site says to include an id in the dropdown menu definition for it to call a callback function every time it is changed
You can probably see my problem now. Since there are 2 id fields within the dropdown menu definition (one for generating the options, the other for calling a function) it is giving me a keyword argument repeated error.
Wondering if anyone can help me out.
Code for reference:
@app.callback(
[Input('my-date-picker-single', 'date'),],
[Output('industry_groups', 'data')])
def get_industry_grps(date):
...some operations...
return out = [
{'label': 'abc', 'value': 'abc'},
{'label': 'def', 'value': 'def'},
{'label': "ghi", 'value': "ghi"},
{'label': 'jkl', 'value': 'jkl'}]
html.Div([
dbc.FormGroup(
[
dbc.Label("Industry Filter:", width=2, align='center',),
dbc.Col(
dcc.Dropdown( id='industry_groups', #(output of the callback function above)
value=['abc', 'def', "ghi", 'jkl'],
id="portfolio_views_exposure_industry_dropdown", #(function to be called after selections within dropdown menu)
multi=True
), ...........style stuff #(deleted to save space)
@app.callback(
[Output(...)],
[...
Input('portfolio_views_exposure_industry_dropdown', 'value'),
...
])
@cache.memoize(timeout=TIMEOUT)
def update_portfolio_utilization_hist_callback(..., industry_group, ...):
...some operations using industry_group
IDper component. In the callback definition, just use the same ID and reference thepropyou want, eitheroptionsorvalue.optionsyou meandata) are the possible selections within the menu. One is upstream and the other downstream so how do I use the same ID