plotly / plotly/plotly.py

[BUG] `dcc.Graph` `figure` prop may include Plotly.js `_inputArray` for typed arrays

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

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

bug P2 size: 3
Ngôn ngữ chính
Python
Star
18.8k
Fork
2.8k
Merge trung bình
16 giờ 26 phút
Pull request đã merge (30 ngày)
21

Mô tả

When a dcc.Graph figure data contains typed arrays (for example int8, float32, etc.), the figure can include a Plotly.js internal field _inputArray

In the example below, the _inputArray is included after user interaction but not when the figure is first rendered.

_inputArray duplicates bdata and also includes decoded data, increasing callback payload size and overhead for large datasets.

Possible fixs:

  • strip _inputArray in dcc.Graph before updating the figure prop. But that might be considered a breaking change since some people are now using _inputArray in callbacks.
  • Have an option to not encode np arrays when using dash. This will also fix the issue of customdata not being available is clickData, hoverData if they are np arrays

Other related issues:


When app first renders (no _inputArray):

Image

After hover (with _inputArray):

Image

Sample App:

from dash import Dash, html, dcc, Input, Output
import numpy as np
import plotly.express as px
import json

app = Dash()

data = np.random.normal(0, 1, 250)
fig = px.histogram(data, nbins=20)

app.layout = html.Div([
    dcc.Graph(id="graph", figure=fig),
    html.Pre(id="fig-data")
])


@app.callback(
    Output("fig-data", "children"),
    Input("graph", "figure"),
    Input("graph", "hoverData"),
)
def debug(figure, hoverData):
    return json.dumps(figure["data"][0]["x"], indent=4)


if __name__ == "__main__":
    app.run(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 ứng dụng Dash mẫu và kiểm tra figure của dcc.Graph trước và sau khi hover, tập trung vào dữ liệu typed-array và trường _inputArray. Theo dõi việc xử lý payload của figure và callback xung quanh dcc.Graph và Plotly.js. Được xem là hoàn thành khi hành vi được chọn cho _inputArray được triển khai nhất quán, hành vi của customdata với typed-array được xem xét và kích thước payload được xác minh.

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, numpy, python
Lĩnh vực
data-visualization
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
50/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.