python - Plotly 自动滚动范围选择器
问题描述
尝试使用视频自动滚动范围选择器。
任何帮助,将不胜感激。下面是我迄今为止尝试过的一些代码,它只呈现原始绘图的范围选择器,但没有自动滚动(即后续绘图)。
使用范围选择器制作甘特图
import plotly.figure_factory as ff
def make_timeline(df, current_time=0):
y = len(df['Task'].unique())
fig = ff.create_gantt(df, height=y * 15, bar_width=0.2, index_col='Resource', show_colorbar=True, group_tasks=True, title='Tags Timeline')
fig.update_layout(
xaxis=dict(
rangeselector=dict(
),
rangeslider=dict(
visible=True
),
type="category",
autorange=False,
range=(current_time, current_time + 30)
)
)
return fig
主仪表板应用程序
import dash_core_components as dcc
app.layout = html.Div(
children=[
dcc.Interval(id="interval-updating-graphs", interval=1000, n_intervals=0),
html.Div(
className="video-outer-container",
children=html.Div(
className="video-container",
children=player.DashPlayer(
id="video-display",
url="https://www.youtube.com/watch?v=9F5FdcVmLOY",#"http://0.0.0.0:8000/PycharmProjects/dash-maf-viz/data/videos/FILE_MAF_20200302T235220Z_SNL-4512-HD.mp4",#"https://www.youtube.com/watch?v=9F5FdcVmLOY",
controls=True,
playing=True,
volume=1,
width="100%",
height="100%",
seekTo=26
),
),
),
html.Div(
id="tags-timeline",
className="eight columns",
children=[
dcc.Graph(id='tags-timeline-graph'),
]
)
)
认为这个回调会通过每秒用不同的起点重绘图形来自动滚动。(这里不包括:我还尝试每 30 秒调用一次 maketimeline() 以防出现延迟,但仍然没有重绘。)
@app.callback(
[Output('tags-timeline-graph', 'figure')],
[Input('video-display', 'currentTime')])
def update_timeline(currentTime):
if currentTime:
pass
else:
currentTime=0
return make_timeline(df, currentTime)
解决方案
推荐阅读
- python-3.x - 什么可以用于自动化 web 服务而不是 selenium-wire?
- r - 问题:无法从 Tripadvisor 获取星级
- python - ValueError:使用 pd.read_html() 时未找到匹配模式“.+”的表
- ag-grid - “空”值的列过滤器
- html - JQuery水平可拖动标尺不平滑
- swift - 嵌入导航栏中时,段控制不起作用[带视频]
- c# - Polly 使用不同的 url 重试
- oracle-apex - 如何为交互式报告添加导航菜单?
- c++ - Blynk.syncVirtual(V1) 不更新虚拟引脚值
- c# - 如何使用来自 ObservableCollection 的 LINQ 查询返回元素?