plotly / plotly/plotly.js

Scattergl freezes when y values have lots of zeros

Đang mở
#6,792 3 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug P2 performance sev-2
Ngôn ngữ chính
JavaScript
Star
18.3k
Fork
2k
Merge trung bình
2 ngày 12 giờ
Pull request đã merge (30 ngày)
28

Mô tả

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)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách chạy bản tái hiện Dash/Python được cung cấp với 200.000 điểm và các giá trị y bằng 0 liên tiếp, sau đó so sánh plotly.js v2.0.0-rc.1 với v2.0.0-rc.2. Đọc các thay đổi liên quan đến scattergl trong PR #5632; được xem là hoàn tất khi thao tác di chuột không còn làm trang bị treo với mẫu dữ liệu được báo cáo, đồng thời hành vi hiện có của Scattergl vẫn được giữ nguyên.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, python
Lĩnh vực
data-visualization, performance
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
38/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.