I was trying to use extendData property of dcc.Graph(), but show the mentioned error. I used the following code. The ext
variable is a array of dictionary as expected by the extendData.
import dash
from dash.dependencies import Output, Input,State
import dash_core_components as dcc
import dash_html_components as html
import plotly
import random
import plotly.graph_objs as go
from collections import deque
import plotly.express as px
import dash
import dash_html_components as html
X =1
app = dash.Dash(__name__)
fig = go.Figure(
data=[go.Scatter(x=[1], y=[1],mode="lines+markers",)],
layout=go.Layout(
title=go.layout.Title(text="A Figure Specified By A Graph Object")
)
)
def serve_layout():
return html.Div([dcc.Graph(id="live-graph",figure=fig), dcc.Interval(
id='graph-update',
interval=10
)])
app.layout = serve_layout
@ app.callback(Output("live-graph", "extendData"),
[Input("graph-update", "interval")],
[State("live-graph", "figure")])
def update_graph_scatter(inter,existing):
global X
x_new = existing['data'][0]['x'][-1] + 1
y_new = random.random()
ext=[dict(x=[[x_new]], y=[[y_new]])]
print(ext)
return ext, [0],100
if __name__ == '__main__':
app.run_server(debug=True)
Can you give me idea where is the problem?