我正在尝试构建一个带有视频的小型应用,并且需要能够实时获取当前视频。该值将用于更新图表,即我想根据当前时间移动垂直shapes
线。
我发现this线程应该可以满足我的需求,但是Events
已从最新的Dash版本中删除,因此无法正常工作。
应用代码:
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children = [
html.Div(children = [
html.Video(
controls = True,
id = 'movie_player',
),
]),
html.Div(children = [
dcc.Graph(
id = 'mean_chart',
figure = {
'data': [go.Scatter(
x = [0,1,2,3,4,5,6,7,8,9,10],
y = [0,1,2,4,5,4,3,5,3,2,1],
)],
'layout': go.Layout(
xaxis = {
'title': 'Second',
'type': 'linear',
},
yaxis = {
'title': 'Average score',
},
shapes = [{
'type': 'line',
'x0': 3,
'y0': -1,
'x1': 3,
'y1': 6,
},]
),
},
),
]),
])
if __name__ == '__main__':
app.run_server(debug = True)
有什么建议吗?