plotly / plotly/plotly.js

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

未关闭
#7,942 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

chore P3 plotly-internal size: 1 task
主要语言
JavaScript
星标
18.3k
派生
2k
平均合并
2 天 12 小时
30 天内合并 PR
28

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 src/components/modebar/buttons.js 和 src/components/modebar/constants.js 开始,追踪按钮名称和 _cat 值如何成为移除别名。更新列出的 modebar 名称和类别,然后运行 npm run schema,并确认 test/plot-schema.json、src/types/generated/schema.d.ts 和 src/types/core/layout.d.ts 反映了公共 API 的变更。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
data-visualization
Issue 类型
重构
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。