Hi,
I’m trying to get three dropdown values on a button click in callback python function. But I am getting only None values.
html.Div([
dcc.Dropdown(
options=[
{'label':'Bar Graph', 'value':'Bar Graph'},
{'label':'Line Graph', 'value':'Line Graph'}
],
id='graph-type',
placeholder='Graph Type'
),
dcc.Dropdown(
options=col_dict_list,
id='x-axis',
placeholder='X Axis Column'
),
dcc.Dropdown(
options=col_dict_list,
id='y-axis',
placeholder='Y Axis Column'
),
html.Button(
'Generate Graph',
id='generate-btn',
style={
'borderRadius': '5px',
'textAlign': 'center',
'margin': '0 auto',
'alignItems': 'center'
},
n_clicks=0
),
]),
@callback(Output('output-graph', 'children'),
State('graph-type', 'graph_type'),
State('x-axis', 'x'),
State('y-axis', 'y'),
Input('generate-btn','n_clicks'))
def generate_graph(graph_type,x,y,n_clicks):
print('checking=',graph_type,x,y,n_clicks)
if graph_type is not None and x is not None and y is not None and n_clicks != 0:
if graph_type == 'bar':
graph = ''
print('checking bar graph')
return graph
Any suggestion/resolution would be helpful, Thanks.