[BUG]: Automargin for quiver plots is a little off with `arrowref: 'paper'`
Chưa có ai nhận issue này.
- 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ả
Desired behavior
Quiver automargin should always result in an initial plot area which contains all arrow endpoints.
Current behavior
The current quiver implementation calculates the arrow endpoints assuming arrowref: 'data', uses those endpoints to compute the automargin extents, and then if arrowref is 'paper'`, applies an adjustment factor to the arrow endpoints.
If the x:y aspect ratio of the data is pretty close to 1:1, this works OK because the arrow endpoints don't change much. But if the aspect ratio of the data is very far from 1:1, this can result in an initial plot where the arrow endpoints extend outside of the plotted area.
Example
Figure definition:
{
"data": [
{
"type": "quiver",
"uhoverformat": ".3f",
"yhoverformat": ".3f",
"xhoverfomrat": ".3f",
"vhoverformat": ".3f",
"x": [0],
"y": [0],
"u": [1],
"v": [0.1],
"arrowref": "paper"
}
],
"layout": {
"width": 800,
"height": 600,
"showlegend": false
}
}
Screenshot:
Notice how the tip of the arrow extends off the right side of the plot.
Fix
The relevant logic is around lines 200-206 in src/traces/quiver/calc.js.
It's a bit of a chicken-and-egg problem, because when arrowref is 'paper', the data position of the arrow endpoints depends on the axis scales, which depend on the position of the arrow endpoints. I think there is probably an algebraic solution but haven't quite been able to figure it out. Alternatively there's probably an iterative or approximate approach we could apply here that would still be an improvement over the current behavior.
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 trong src/traces/quiver/calc.js quanh các dòng 200-206 và tái tạo hình quiver được cung cấp với arrowref được đặt thành paper. Theo dõi cách các điểm cuối của mũi tên và các phạm vi automargin được tính toán tương ứng với các thang đo của trục. Được xem là hoàn thành khi vùng biểu đồ ban đầu chứa tất cả các điểm cuối của mũi tên, kể cả khi tỷ lệ khung hình của dữ liệu khác 1:1 đáng kể.
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
- 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
- 55/100