On_selection event in faceted plot only works correctly in first facet
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ả
Hello,
I’m trying to catch on_selection events in a faceted figure.
I create a simple faceted figure, and attach an on_selection handler to all traces.
As an output, I simply print the customdata, and the selector.xrange.
When selecting an area in the first facet, the selector.xrange is an array of numbers, the customdata corresponds to the data for the left facet.
However, when I do the same in the second facet, the selector.xrange becomes an , and the customdata still appears to be coming from the left facet.
I expect the selector.xrange to also be an array of numbers, when selecting in the right facet.
Here are the sample code (to be executed in jupyter notebook) and a screenshot of the result.
py.init_notebook_mode()
df = pd.DataFrame({
"x": [1,2,3,4,1,2,3,4],
"y": [1,2,3,2,1,4,2,3],
"side": ["left","left","left","left","right","right","right","right"],
"customdata": [1,2,3,4,5,6,7,8]
})
fig = px.line(df, x="x", y="y", custom_data=["side","customdata"], facet_col="side")
# fig.update_layout(clickmode='event+select')
fig.update_layout(
dragmode="select",
clickmode="select"
)
fig.update_traces(marker_size=20)
f = go.FigureWidget(fig)
def click_handler(trace, points, selector):
print(trace.customdata)
print(selector.xrange)
f.data[0].on_selection(click_handler)
f
Kind Regards
Bart
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
Chạy ví dụ faceted-plot được cung cấp trong một Jupyter notebook và kiểm tra callback lựa chọn của FigureWidget được gắn thông qua f.data[0].on_selection. So sánh selector.xrange và trace.customdata khi chọn facet bên trái và bên phải. Được xem là hoàn tất khi các lựa chọn trong cả hai facet báo cáo phạm vi số và dữ liệu facet tương ứng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- jupyter-notebook, python
- Lĩnh vực
- data-visualization
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 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