Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions types/plotly.js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@ export interface ModeBar {
uirevision: number | string;
}

export type ModeBarButtonAny = ModeBarDefaultButtons | ModeBarButton;

export type ModeBarDefaultButtons =
| 'lasso2d'
| 'select2d'
Expand Down Expand Up @@ -903,7 +905,12 @@ export type ModeBarDefaultButtons =
| 'toggleHover'
| 'toImage'
| 'resetViews'
| 'toggleSpikelines';
| 'toggleSpikelines'
| 'togglespikelines'
| 'togglehover'
| 'hovercompare'
| 'hoverclosest'
| 'v1hovermode';

export type ButtonClickEvent = (gd: PlotlyHTMLElement, ev: MouseEvent) => void;

Expand Down Expand Up @@ -1612,15 +1619,15 @@ export interface Config {
modeBarButtonsToRemove: ModeBarDefaultButtons[];

/** add mode bar button using config objects (see ./components/modebar/buttons.js for list of arguments) */
modeBarButtonsToAdd: ModeBarDefaultButtons[] | ModeBarButton[];
modeBarButtonsToAdd: ModeBarButtonAny[];

/**
* fully custom mode bar buttons as nested array, where the outer
* arrays represents button groups, and the inner arrays have
* buttons config objects or names of default buttons
* (see ./components/modebar/buttons.js for more info)
*/
modeBarButtons: Array<Array<ModeBarDefaultButtons | ModeBarButton>> | false;
modeBarButtons: ModeBarButtonAny[][] | false;

/** add the plotly logo on the end of the mode bar */
displaylogo: boolean;
Expand Down
23 changes: 23 additions & 0 deletions types/plotly.js/test/index-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,29 @@ const graphDiv = '#test';
],
['toImage'],
],
// mix strings from ModeBarDefaultButtons and custom button added as ModeBarButton interface
modeBarButtonsToAdd: [
'togglespikelines',
'togglehover',
'hovercompare',
'hoverclosest',
'v1hovermode',
{
name: 'save',
title: 'Download plot data',
icon: {
width: 857.1,
height: 1000,
path:
'm214-7h429v214h-429v-214z m500 0h72v500q0 8-6 21t-11 20l-157 156q-5 6-19 12t-22 5v-232q0-22-15-38t-38-16h-322q-22 0-37 16t-16 38v232h-72v-714h72v232q0 22 16 38t37 ' +
'16h465q22 0 38-16t15-38v-232z m-214 518v178q0 8-5 13t-13 5h-107q-7 0-13-5t-5-13v-178q0-8 5-13t13-5h107q7 0 13 5t5 13z m357-18v-518q0-22-15-38t-38-16h-750q-23 0-38 ' +
'16t-16 38v750q0 22 16 38t38 16h517q23 0 50-12t42-26l156-157q16-15 27-42t11-49z',
ascent: 850,
transform: 'matrix(1 0 0 -1 0 850)',
},
click: (gd, ev) => console.log('Download data'),
}
],
setBackground: 'transparent',
watermark: false,
};
Expand Down