File tree 2 files changed +20
-4
lines changed 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -40,16 +40,26 @@ module.exports = function manageModeBar(gd) {
40
40
] . join ( ' ' ) ) ;
41
41
}
42
42
43
- // if(!Array.isArray(context.m))
43
+ if ( ! Array . isArray ( context . modeBarButtonsToAdd ) ) {
44
+ throw new Error ( [
45
+ '*modeBarButtonsToAdd* configuration options' ,
46
+ 'must be an array.'
47
+ ] . join ( ' ' ) ) ;
48
+ }
49
+
44
50
45
- var buttonGroups = getButtonGroups ( fullLayout , context . modeBarButtonsToRemove ) ;
51
+ buttonGroups = getButtonGroups (
52
+ fullLayout ,
53
+ context . modeBarButtonsToRemove ,
54
+ context . modeBarButtonsToAdd
55
+ ) ;
46
56
47
57
if ( modeBar ) modeBar . update ( gd , buttonGroups ) ;
48
58
else fullLayout . _modeBar = createModeBar ( gd , buttonGroups ) ;
49
59
} ;
50
60
51
61
// logic behind which buttons are displayed by default
52
- function getButtonGroups ( fullLayout , buttonsToRemove ) {
62
+ function getButtonGroups ( fullLayout , buttonsToRemove , buttonsToAdd ) {
53
63
var groups = [ ] ;
54
64
55
65
function addGroup ( newGroup ) {
@@ -97,6 +107,8 @@ function getButtonGroups(fullLayout, buttonsToRemove) {
97
107
addGroup ( [ 'hoverClosestPie' ] ) ;
98
108
}
99
109
110
+ if ( buttonsToAdd . length ) groups . push ( buttonsToAdd ) ;
111
+
100
112
return groups ;
101
113
}
102
114
Original file line number Diff line number Diff line change @@ -58,10 +58,14 @@ module.exports = {
58
58
// display the mode bar (true, false, or 'hover')
59
59
displayModeBar : 'hover' ,
60
60
61
- // remove modebar button by name
61
+ // remove mode bar button by name
62
62
// (see ./components/modebar/buttons.js for the list of names)
63
63
modeBarButtonsToRemove : [ ] ,
64
64
65
+ // add mode bar button using config objects
66
+ // (see ./components/modebar/buttons.js for list of arguments)
67
+ modeBarButtonsToAdd : [ ] ,
68
+
65
69
// add the plotly logo on the end of the mode bar
66
70
displaylogo : true ,
67
71
You can’t perform that action at this time.
0 commit comments