Skip to content

Commit bc09b2a

Browse files
authored
Merge pull request #7941 from plotly/cam/7939/add-values-ModeBarDefaultButtons
fix: Add missing values to ModeBarDefaultButtons type
2 parents 21bf8c2 + f4e742c commit bc09b2a

1 file changed

Lines changed: 45 additions & 18 deletions

File tree

src/types/core/layout.d.ts

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,47 +36,74 @@ export type AxisName = XAxisName | YAxisName;
3636
// ---------------------------------------------------------------------------
3737

3838
/**
39-
* Names of built-in mode-bar buttons. Used by `config.modeBarButtonsToAdd`
40-
* and `config.modeBarButtonsToRemove` to reference Plotly's defaults.
39+
* Identifiers for Plotly's built-in mode-bar buttons. Which of these a config
40+
* option accepts differs:
41+
*
42+
* - `config.modeBarButtonsToRemove` — any identifier below. Removal matches
43+
* case-insensitively against each default button's `name` and its category.
44+
* - `config.modeBarButtons` — the button's registry key, resolved against
45+
* Plotly's button table; an unknown key throws.
46+
* - `config.modeBarButtonsToAdd` — as a *string*, only the shape-drawing
47+
* buttons (`drawline` … `eraseshape`) and the category aliases at the end of
48+
* this union. Any other button has to be added as a `ModeBarButton` object;
49+
* passing its name as a string does not resolve to the built-in button.
4150
*/
4251
export type ModeBarDefaultButtons =
43-
| 'lasso2d'
44-
| 'select2d'
45-
| 'sendDataToCloud'
52+
// Cartesian
4653
| 'zoom2d'
4754
| 'pan2d'
55+
| 'select2d'
56+
| 'lasso2d'
4857
| 'zoomIn2d'
4958
| 'zoomOut2d'
5059
| 'autoScale2d'
5160
| 'resetScale2d'
52-
| 'hoverClosestCartesian'
53-
| 'hoverCompareCartesian'
61+
// 3D
5462
| 'zoom3d'
5563
| 'pan3d'
5664
| 'orbitRotation'
5765
| 'tableRotation'
58-
| 'handleDrag3d'
5966
| 'resetCameraDefault3d'
6067
| 'resetCameraLastSave3d'
61-
| 'hoverClosest3d'
68+
// Geo
6269
| 'zoomInGeo'
6370
| 'zoomOutGeo'
6471
| 'resetGeo'
72+
// Map
73+
| 'zoomInMap'
74+
| 'zoomOutMap'
75+
| 'resetViewMap'
76+
// Sankey. `resetViewSankey` is the button's object key (for `config.modeBarButtons`
77+
// custom groups); `resetSankeyGroup` is its `name` (for `modeBarButtonsToRemove`).
78+
| 'resetViewSankey'
79+
| 'resetSankeyGroup'
80+
// Hover
81+
| 'hoverClosestCartesian'
82+
| 'hoverCompareCartesian'
83+
| 'hoverClosest3d'
6584
| 'hoverClosestGeo'
66-
| 'hoverClosestGl2d'
6785
| 'hoverClosestPie'
6886
| 'toggleHover'
87+
| 'toggleSpikelines'
88+
// Shape drawing
89+
| 'drawline'
90+
| 'drawopenpath'
91+
| 'drawclosedpath'
92+
| 'drawcircle'
93+
| 'drawrect'
94+
| 'eraseshape'
95+
// Other
6996
| 'toImage'
97+
| 'sendChartToCloud'
7098
| 'resetViews'
71-
| 'toggleSpikelines'
72-
| 'zoomInMap'
73-
| 'zoomOutMap'
74-
| 'resetViewMap'
75-
| 'togglespikelines'
76-
| 'togglehover'
77-
| 'hovercompare'
99+
// Category aliases. `modeBarButtonsToRemove` matches case-insensitively against a
100+
// button's `name` and its category, and `modeBarButtonsToAdd` accepts these strings
101+
// to re-enable the corresponding hover buttons.
102+
| 'v1hovermode'
78103
| 'hoverclosest'
79-
| 'v1hovermode';
104+
| 'hovercompare'
105+
| 'togglehover'
106+
| 'togglespikelines';
80107

81108
/** Click handler signature for custom mode-bar buttons. */
82109
export type ButtonClickEvent = (gd: PlotlyHTMLElement, ev: MouseEvent) => void;

0 commit comments

Comments
 (0)