File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -47,12 +47,19 @@ module.exports = function manageModeBar(gd) {
47
47
] . join ( ' ' ) ) ;
48
48
}
49
49
50
+ var customButtons = context . modeBarButtons ;
51
+ var buttonGroups ;
50
52
53
+ if ( Array . isArray ( customButtons ) && customButtons . length > 1 ) {
54
+ buttonGroups = fillCustomButton ( customButtons ) ;
55
+ }
56
+ else {
51
57
buttonGroups = getButtonGroups (
52
58
fullLayout ,
53
59
context . modeBarButtonsToRemove ,
54
60
context . modeBarButtonsToAdd
55
61
) ;
62
+ }
56
63
57
64
if ( modeBar ) modeBar . update ( gd , buttonGroups ) ;
58
65
else fullLayout . _modeBar = createModeBar ( gd , buttonGroups ) ;
@@ -125,3 +132,27 @@ function areAllAxesFixed(fullLayout) {
125
132
126
133
return allFixed ;
127
134
}
135
+
136
+ // fill in custom buttons referring to default mode bar buttons
137
+ function fillCustomButton ( customButtons ) {
138
+ for ( var i = 0 ; i < customButtons . length ; i ++ ) {
139
+ var buttonGroup = customButtons [ i ] ;
140
+
141
+ for ( var j = 0 ; j < buttonGroup . length ; j ++ ) {
142
+ var button = buttonGroup [ j ] ;
143
+
144
+ if ( typeof button === 'string' )
145
+ if ( modeBarButtons [ button ] !== undefined ) {
146
+ customButtons [ i ] [ j ] = modeBarButtons [ button ] ;
147
+ }
148
+ else {
149
+ throw new Error ( [
150
+ '*modeBarButtons* configuration options' ,
151
+ 'invalid button name'
152
+ ] . join ( ' ' ) ) ;
153
+ }
154
+ }
155
+ }
156
+
157
+ return customButtons ;
158
+ }
Original file line number Diff line number Diff line change @@ -66,6 +66,12 @@ module.exports = {
66
66
// (see ./components/modebar/buttons.js for list of arguments)
67
67
modeBarButtonsToAdd : [ ] ,
68
68
69
+ // fully custom mode bar buttons as nested array,
70
+ // where the outer arrays represents button groups, and
71
+ // the inner arrays have buttons config objects or names of default buttons
72
+ // (see ./components/modebar/buttons.js for more info)
73
+ modeBarButtons : false ,
74
+
69
75
// add the plotly logo on the end of the mode bar
70
76
displaylogo : true ,
71
77
You can’t perform that action at this time.
0 commit comments