I want to plot a graph which takes three Inputs from a callback, which contains the DateRangePicker values and a multiple dropdown menu.
After i run my Code i recieve a “Syntax error” message. I put a picture of it below.
I tried only the DateRangePicker as Input and it worked. But when i try do the same with the multiple dropdown menu it shows me the defined error message.
i would appreciate if anyone could help me with this issue.
@app.callback(
Output('plot_1', 'figure'),
[Input('DatePicker', 'start_date'),
Input('DatePicker', 'end_date'),
Input('multi_dropdown', 'value')])```
def update_graph_1(selected_start_date, selected_end_date, selected_product):
filtered_df1 = df[(df['DateTimeUTC'] >= selected_start_date) & (df['DateTimeUTC'] < selected_end_date)]
if type(selected_product)!=str:
filtered_product = filtered_df1[filtered_df1['Time'].isin(selected_product)]
else:
filtered_product = filtered_df1[filtered_df1['Time']==selected_product]
traces = []
traces.append(go.Scatter(
x = filtered_product['Time_StampUTC'],
y = filtered_product['Price'],
mode = 'lines',
marker={
... 'size': 15,
... 'opacity': 0.5,
... 'line': {'width': 0.5, 'color': 'white'}
... }
))
return {'data': traces,
'layout': go.Layout(
xaxis = {'title': 'title_1',
'showgrid': False},
yaxis = {'title': 'title_2',
'showgrid': False},
hovermode='closest',
paper_bgcolor = 'rgba(0,0,0,0)',
plot_bgcolor = 'rgba(0,0,0,0)',
title = 'Scatterplot',
title_font_size = 14
)
}
if __name__ == '__main__':
app.run_server()
`