I’m a beginner in Dash and plotly. I would like to create a interactive graphing like it’s explained in the tutorial : https://dash.plot.ly/interactive-graphing [https://dash.plot.ly/interactive-graphing]
I have followed this example but it doesn’t work and I don’t know why.
here is my code :
df = pd.DataFrame(...)
app = dash.Dash()
styles = {
'pre': {
'border': 'thin lightgrey solid',
'overflowX': 'scroll'
}
}
app.layout = html.Div(children=[
html.H1(
children='My title',
style={
'textAlign': 'center',
'color': 'black'
}
),
html.Div(children='subtitle', style={
'textAlign': 'center',
'color': 'black'}),
html.Div([dcc.Graph(id="id_map",figure="my_figure")]),
html.Div(dcc.Graph(id = 'id_interactive_graph'))
])
@app.callback(
Output('id_interative_graph', 'figure'),
[Input('id_map', 'clickData')])
def update_figure(clickData):
click = clickData['points'][0]["customdata"]
print(f(df,click)
return f(df,click)
## f return a dictionnary : { "data" : [...]; "layout" : {...} }
if __name__ == '__main__':
app.run_server(debug = True)
The problem is that the graph “id_interactive_graph” isn’t displayed but no error is raised.
The function f() works properly. I can verify it, with the print().
The format of the result of this function it’s correct too ; I’ve ever tried to put the result directly in the app.layout().
The callback works because I’ve ever tried to return a more simple figure which is displayed.
The clickData works well too, I’ve ever succeeded in displaying the “click”.
All works well separately but not in interraction.
I don’t understand at all what’s happening.
Is it possible that my function f() is a too long dictionary too be displayed ?