plotly / plotly/plotly.js

Scattergl freezes when y values have lots of zeros

オープン
#6,792 コメント 3 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P2 performance sev-2
主要言語
JavaScript
スター
18.3k
フォーク
2k
平均マージ
2日 12時間
マージ済み PR(30日)
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)

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、200,000 個のポイントと連続する y 値 0 を使って、提供された 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。