File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 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) {
4040 ] . join ( ' ' ) ) ;
4141 }
4242
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+
4450
45- var buttonGroups = getButtonGroups ( fullLayout , context . modeBarButtonsToRemove ) ;
51+ buttonGroups = getButtonGroups (
52+ fullLayout ,
53+ context . modeBarButtonsToRemove ,
54+ context . modeBarButtonsToAdd
55+ ) ;
4656
4757 if ( modeBar ) modeBar . update ( gd , buttonGroups ) ;
4858 else fullLayout . _modeBar = createModeBar ( gd , buttonGroups ) ;
4959} ;
5060
5161// logic behind which buttons are displayed by default
52- function getButtonGroups ( fullLayout , buttonsToRemove ) {
62+ function getButtonGroups ( fullLayout , buttonsToRemove , buttonsToAdd ) {
5363 var groups = [ ] ;
5464
5565 function addGroup ( newGroup ) {
@@ -97,6 +107,8 @@ function getButtonGroups(fullLayout, buttonsToRemove) {
97107 addGroup ( [ 'hoverClosestPie' ] ) ;
98108 }
99109
110+ if ( buttonsToAdd . length ) groups . push ( buttonsToAdd ) ;
111+
100112 return groups ;
101113}
102114
Original file line number Diff line number Diff line change @@ -58,10 +58,14 @@ module.exports = {
5858 // display the mode bar (true, false, or 'hover')
5959 displayModeBar : 'hover' ,
6060
61- // remove modebar button by name
61+ // remove mode bar button by name
6262 // (see ./components/modebar/buttons.js for the list of names)
6363 modeBarButtonsToRemove : [ ] ,
6464
65+ // add mode bar button using config objects
66+ // (see ./components/modebar/buttons.js for list of arguments)
67+ modeBarButtonsToAdd : [ ] ,
68+
6569 // add the plotly logo on the end of the mode bar
6670 displaylogo : true ,
6771
You can’t perform that action at this time.
0 commit comments