Scattergl freezes when y values have lots of zeros
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 18.3k
- 派生
- 2k
- 平均合并
- 2 天 12 小时
- 30 天内合并 PR
- 28
描述
This might be more to do with plotly.js or plotly.py, but I only have dash code to generate the plot so I am posting here. I do a lot of time series plotting for my work, so Scattergl comes in handy because I routinely plot 1000's of points on a trace. After updating to dash 1.21.0, I noticed the Scattergl plots hang on hovering when my trace has lots of consecutive zero y-values. In most cases the hover event will freeze the entire page and I need to close and reopen the page.
EDIT: I pinpointed this error to the upgrade from plotly.js v2.0.0-rc.1 to plotly.js v2.0.0-rc.2. If you put rc.1 in the assets folder, scattergl works fast like in the previous version of dash. If you put rc.2 in the assets folder, the issues return.
I am not a js developer, so I don't know how best to move this issue over to plotly.js with equivalent js example. Nevertheless, I looked the difference in rc.1 and rc.2 changelogs and found that in rc.2 there is an additional reference to scattergl: Improve scattergl performance when using typed arrays #5632, maybe that is causing the issue?
Check the code below for an example:
import plotly.graph_objects as go
import numpy as np
import dash
import dash_core_components as dcc
import pandas as pd
import random
# build dataset
N = 200000
index = pd.date_range("7/1/2020", "7/1/2021", N)
vals = np.zeros(N)
# add some random non-zero data around the dataset
for i in range(50):
start = random.randint(0, N - 50)
vals[start : start + 50] = np.random.random(50)
# uncomment this line and see how Scattergl is much faster without the consecutive zeros
# vals = np.random.random(N)
# change Scattergl to Scatter to see how Scatter performs better with consecutive zeros
fig = go.Figure()
fig.add_trace(
go.Scattergl(
x=index,
y=vals,
)
)
app = dash.Dash()
app.layout = dcc.Graph(figure=fig)
if __name__ == "__main__":
app.run_server(host="0.0.0.0", port=8080, debug=True)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,使用 200,000 个点和连续的零 y 值运行提供的 Dash/Python 重现,然后比较 plotly.js v2.0.0-rc.1 与 v2.0.0-rc.2。阅读 PR #5632 中与 scattergl 相关的更改;当对于所报告的数据模式,悬停不再导致页面冻结,同时现有的 Scattergl 行为保持不变时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, python
- 领域
- data-visualization, performance
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100