Hi,
I’m trying to build some dashboard which will show me some real time data from live experiment. I had it worked, but once I’ve tried to upgrade it, it is not working anymore. Here is the idea of my code
app.layout = html.Div([
...
dcc.Store(id='time'),
dcc.Store(id='old_data'),
...
html.Div([
dcc.Graph(id='figure1'),
dcc.Interval(
id='interval-component',
interval=1*1000, # in milliseconds
n_intervals=0
)
])
])
@callback([Output('old_data', 'data'),
Output('time', 'data'),]
Input('interval-component', 'n_intervals'),
[State('time', 'data'),
State('data', 'data')]
)
def update_graph_live(n,time1,prev_data):
if time1 is None:
time=0
prev_data = pd.to_json(pd.DataFrame({}))
else:
a= pd.read_sql('SELECT * FROM test_data where Time >', time1, conn)
prev_data1 = a+prev_data
prev_data = pd.to_json()
time = time1+1
return prev_data, time
The problem is that each time the callback is executed, the time1 value is getting None
value. Please assist me to solve the problem for this.