[BUG] `dcc.Graph` `figure` prop may include Plotly.js `_inputArray` for typed arrays
Chưa có ai nhận issue này.
- 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
_inputArrayin dcc.Graph before updating thefigureprop. But that might be considered a breaking change since some people are now using_inputArrayin callbacks. - Have an option to not encode np arrays when using dash. This will also fix the issue of
customdatanot being available isclickData,hoverDataif they are np arrays
Other related issues:
- Need a way to covert the typed arrays so the data is usable in a dash callback: https://github.com/plotly/dash/issues/3307
When app first renders (no _inputArray):
After hover (with _inputArray):
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
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- 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