I'm currently trying to draw density heatmap which gets updated in real time. This is the figure and app layout that I've defined.
figure = dict({
"data" : [{"type": 'heatmap',
"x" : [],
"y" : []}],
"layout" : {"xaxis" : [0,255], "yaxis" : [0,255]}
})
app.layout = html.Div(children=[
html.Div([
html.H1(children='Sensor Data'),
html.Div(children='''
3d Representation.
'''),
dcc.Graph(
id='live-update-graph',
figure = figure
),
]),
dcc.Interval(
id = 'clientside-time',
interval = 10,
n_intervals = 0
)
])
This is the callback function which is supposed to update data each time.
phase = [i for i in range(256)]
phases = []
cycle = []
phases = phase *5
cycle = [[i] *256 for i in range(5)]
cycle = list(chain.from_iterable(cycle))
@app.callback(
Output('live-update-graph', 'extendData'),
Input('clientside-time', 'n_intervals')
)
def update_store_data(time):
df = DataFrame(storage[256*time : (time+5) * 256], columns = ['Intensity'] )
df['Phase'] = phases
print(time)
return dict(x = [df['Phase']], y = [df['Intensity']])
if __name__ == '__main__':
app.run_server(debug=True)
In my theory, list slicing is supposed to get different portion from storage list which has been initialized above. However, I don't see any graphs drawn after running this code. Is this the correct way to update data with a change in time?