Skip to content

Commit 154431f

Browse files
committed
add buttonstoadd to layout.modebar
1 parent 117e39c commit 154431f

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

src/components/modebar/attributes.js

+23
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,28 @@ module.exports = {
3737
'root level and inside subplots. Defaults to `layout.uirevision`.'
3838
].join(' ')
3939
},
40+
buttonstoadd: {
41+
valType: 'flaglist',
42+
flags: [
43+
'v1hovermode',
44+
'hoverclosest',
45+
'hovercompare',
46+
'togglehover',
47+
'togglespikelines',
48+
'drawclosedpath',
49+
'drawopenpath',
50+
'drawline',
51+
'drawrect',
52+
'drawcircle',
53+
'eraseshape',
54+
],
55+
dflt: '',
56+
editType: 'modebar',
57+
description: [
58+
'Determines which predefined modebar buttons to add.',
59+
'Please note that these buttons will only be shown if they are compatible',
60+
'with all trace types used in a graph.'
61+
].join(' ')
62+
}
4063
}
4164
};

src/components/modebar/defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
1515
coerce('modebar.color', Color.addOpacity(defaultColor, 0.3));
1616
coerce('modebar.activecolor', Color.addOpacity(defaultColor, 0.7));
1717
coerce('modebar.uirevision', layoutOut.uirevision);
18+
coerce('modebar.buttonstoadd');
1819
};

src/components/modebar/manage.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ function getButtonGroups(gd) {
7272
var fullLayout = gd._fullLayout;
7373
var fullData = gd._fullData;
7474
var context = gd._context;
75+
var layoutButtonsToAdd = fullLayout.modebar.buttonstoadd.split('+');
76+
var buttonsToAdd = context.modeBarButtonsToAdd.concat(layoutButtonsToAdd);
7577
var buttonsToRemove = context.modeBarButtonsToRemove;
76-
var buttonsToAdd = context.modeBarButtonsToAdd;
7778

7879
var hasCartesian = fullLayout._has('cartesian');
7980
var hasGL3D = fullLayout._has('gl3d');

test/jasmine/tests/modebar_test.js

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ describe('ModeBar', function() {
4242
_has: Plots._hasPlotType,
4343
_subplots: {xaxis: xaxes || [], yaxis: yaxes || []},
4444
modebar: {
45+
buttonstoadd: '',
4546
orientation: 'h',
4647
bgcolor: 'rgba(255,255,255,0.7)',
4748
color: 'rgba(0, 31, 95, 0.3)',

0 commit comments

Comments
 (0)