plotly / plotly/plotly.js

[CHORE]: Update modebar button names to be more accurate/consistent

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

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

chore P3 plotly-internal size: 1 task
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ả

Description

Update existing modebar button/group names to be more accurate/consistent.

Three related inconsistencies in how modebar buttons are named:

  • resetViewSankey reports a different name than its key. It is registered as modeBarButtons.resetViewSankey but carries name: 'resetSankeyGroup' - the only mismatch among the 37 buttons. Removing it therefore requires modeBarButtonsToRemove: ['resetSankeyGroup'], while config.modeBarButtons groups use 'resetViewSankey'.
  • _cat: 'reset' matches only resetGeo. It reads like a category but leaves resetViews, resetScale2d, resetViewMap, and the sankey reset in place.
  • _cat: 'resetView' matches only resetViewMap, so it misses the sankey reset despite the name suggesting otherwise.

All of these strings are advertised in the layout.modebar.remove enumeration (48 entries), so they are public API.

Why should this change be made?

Users reasonably expect a button's removal string to match its key, and a category alias to cover a family. Today remove: 'reset' and remove: 'resetView' silently no-op on most reset buttons, and the sankey button can only be removed by a name that appears
nowhere else. Compare the aliases that do behave as categories: zoom (2 buttons), pan (2), zoomin / zoomout (3 each), hoverclosest (4).

Scope
  • src/components/modebar/buttons.js - name on resetViewSankey, and the _cat values for reset / resetView.
  • src/components/modebar/constants.js builds foreButtons from name + _cat, so any change regenerates the schema enumeration (npm run schema, committing test/plot-schema.json and src/types/generated/schema.d.ts).
  • src/types/core/layout.d.ts - ModeBarDefaultButtons currently lists both resetViewSankey and resetSankeyGroup
Notes
  • All of these changes are breaking
  • Nothing is wrong with the current code, but it can be confusing
  • _cat casing is inconsistent (hoverCompare, resetCameraDefault, resetView vs hoverclosest, zoomin, autoscale) and should be addressed at the same time (though it's only cosmetic)
  • Every item breaks working code - renaming the sankey name invalidates modeBarButtonsToRemove: ['resetSankeyGroup'], and widening the _cat aliases makes existing remove calls take out more buttons. So this belongs in a major release; v4 is the window if it's wanted at all. Separately, _cat casing is inconsistent (hoverCompare, resetCameraDefault, resetView vs hoverclosest, zoomin, autoscale) - cosmetic only, since matching lowercases both sides.

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 từ src/components/modebar/buttons.js và src/components/modebar/constants.js để lần theo cách tên nút và các giá trị _cat trở thành các bí danh loại bỏ. Cập nhật các tên và danh mục modebar được liệt kê, sau đó chạy npm run schema và xác minh rằng test/plot-schema.json, src/types/generated/schema.d.ts và src/types/core/layout.d.ts phản ánh các thay đổi của API công khai.

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
Tái cấu trúc
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/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.