I am working on data visualization task in which used Dash from plotly(python). When I am running the code I got an error which is -
ImportError: cannot import name 'Event'
I have tried various installation processes like pip install events or pip install Event, but I am not able to solve my error.
code:
import dash
from dash.dependencies import Output, Event
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
x = deque(maxlen=20)
y = deque(maxlen=20)
x.append(1)
y.append(1)
app = dash.Dash(__name__)
app.layout = html.Div(
[
dcc.Graph(id = 'live-graph', animate = True),
dcc.Interval(
id = 'graph-update',
interval = 1000
)
]
)
@app.callback(Output('live-graph','figure'),
events = [Event('graph-update','interval')])
def update_graph():
globalx
globaly
x.append(x[-1]+1)
y.append(y[-1]+(y[-1]*random.uniform(-0.1,0.1)))
data = go.Scatter(
x = list (x),
y = list(y),
name = 'Scatter',
mode = 'lines+markers'
)
return {'data':[data],'layout':go.Layout(xaxis = dict(range = [min(x), max(x)]),
yaxis = dict(range = [min(y), max(y)]))}
if __name__ == '__main__':
app.run_server(debug = True, port = 8051)