Hi,
I have been trying to create two line graphs based on the inputs from dropdowns and daterange. The data is fetched through APIs. In the first method for the first graph i am getting all the data wherein the global df is updated. I am trying to access the df in the second method for the second graph. It does not look like i am able to.
import json
import pandas as pd
global df
app = dash.Dash()
app.layout = html.Div([
dcc.Graph(id='graph1', figure={
'data':[
{'x':[1,1], 'y':[1,1]}
]
}),
dcc.Graph(id = 'graph2', figure={
'data':[
{'x':[1,1], 'y':[1,1]}
]
})
@app.callback(Output('graph1','figure'),
[Input ('AAA','figure'])
def update_graph1 (input params):
'''Data retrieval happens here'''
df['A'] = series1
df['B'] = series2
return fig1
@app.callback(Output('graph2','figure'),
[Input ('BBB','figure'])
def update_graph2 (input params):
'''the df['A'] and df['B'] can not be accessed here - I don't want to repeat the data retrieval
here as it would be computationally expensive'''
if __name__ == '__main__':
app.run_server(debug=True)
Any guidance would be highly appreciated
Thanks