Updating dropdown dcc based on a radioitem dcc

i have the following dash code:

data_type = [‘F’, ‘M’, ‘R’]
data_dict = {‘F’: [‘x’, ‘y’], ‘M’:[‘z’, ‘t’], ‘R’: [‘f’, ‘r’] }
plot_type = [‘Chi’, ‘AD’, ‘KS’]
app = Dash()

app.layout = html.Div(id = ‘main-div’,
html.H4(‘Raw data Statistical tests’),
html.P(‘Chose data type:’),
dcc.RadioItems(data_type, data_type[0], id = ‘type-picker’),
html.P(‘Chose data:’),
dcc.Dropdown(id = ‘data-picker’, multi = True),
html.P(‘Chose R-test type:’),
dcc.RadioItems([‘Row’, ‘All’]),
html.P(‘Chose plot:’),
dcc.RadioItems(plot_type, plot_type[0], id=‘plot-picker’),
dcc.Graph(id = ‘plot’)


@app.callback(Output(‘data-picker’,‘value’), [Input(‘type-picker’, ‘value’)])
def data_picker(data_type):
return data_dict[data_type]

if name ==‘main’:
app.run_server(debug=True, use_reloader=False)

I want the dcc.Dropdown menu to be updated based in the previous dcc.RadioItems element.
I tried to use the @callback function but I didn’t succeed.
Any Ideas how to achieve this?


I replied on stackoverflow but not sure did you read it or not so I reply here again. You should change Output('data-picker','value') to Output('data-picker','options') because you need to return options, not value.

1 Like

Thanks. But i have another important question, how can i refer back to the drop down option in another callback’s function?

You mean that you want to use dropdown value to return another Output?