I want to update the live-graph in such a way that, while new data point comes while only that data point/points will add instead of re-drawing all the previous data mainly because increase performance of the real time system.
From this and this discussion, I found dash-extendable-graph · PyPI .
The example code which updates X and Y works fine. But I wanted that the newly added data points with different marker symbol. But this is not working. I have tried the following code:
import dash_extendable_graph as deg
import dash
from dash.dependencies import Input, Output, State
import dash_html_components as html
import dash_core_components as dcc
import random
app = dash.Dash(__name__)
app.scripts.config.serve_locally = True
app.css.config.serve_locally = True
app.layout = html.Div([
deg.ExtendableGraph(
id='extendablegraph_example',
figure=dict(
data=[{'x': [0],
'y': [0],
'mode':'lines+markers',
'marker':{'symbol':'circle'}
}],
)
),
dcc.Interval(
id='interval_extendablegraph_update',
interval=5,
n_intervals=0,
max_intervals=-1),
html.Div(id='output')
])
@app.callback(Output('extendablegraph_example', 'extendData'),
[Input('interval_extendablegraph_update', 'n_intervals')],
[State('extendablegraph_example', 'figure')])
def update_extendData(n_intervals, existing):
x_new = existing['data'][0]['x'][-1] + 1
y_new = random.random()
return [dict(x=[x_new], y=[y_new],marker=dict(symbol=['cross']))], [0], 100
if __name__ == '__main__':
app.run_server(debug=True)
How can I achieve this?