Skip to content

Commit b252c88

Browse files
committed
reverse axis modebar disabling logic and update names
1 parent e361533 commit b252c88

File tree

6 files changed

+19
-46
lines changed

6 files changed

+19
-46
lines changed

src/components/modebar/buttons.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ function handleCartesian(gd, ev) {
260260

261261
for(i = 0; i < axList.length; i++) {
262262
ax = axList[i];
263-
allowed = ax.modebarbuttons === 'all' || ax.modebarbuttons.indexOf(
264-
(val === 'auto' || val === 'reset') ? 'auto' : 'inout'
265-
) !== -1;
263+
allowed = ax.modebardisable === 'none' || ax.modebardisable.indexOf(
264+
(val === 'auto' || val === 'reset') ? 'autoscale' : 'zoominout'
265+
) === -1;
266266

267267
if(allowed && !ax.fixedrange) {
268268
axName = ax._name;

src/components/modebar/manage.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ function areAllAxesFixed(fullLayout) {
269269
var axList = axisIds.list({_fullLayout: fullLayout}, null, true);
270270

271271
for(var i = 0; i < axList.length; i++) {
272-
if(!axList[i].fixedrange && axList[i].modebarbuttons !== 'none') {
272+
var disabled = axList[i].modebardisable;
273+
if(!axList[i].fixedrange && disabled !== 'autoscale+zoominout' && disabled !== 'zoominout+autoscale') {
273274
return false;
274275
}
275276
}

src/plots/cartesian/layout_attributes.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,16 +389,16 @@ module.exports = {
389389
'If true, then zoom is disabled.'
390390
].join(' ')
391391
},
392-
modebarbuttons: {
392+
modebardisable: {
393393
valType: 'flaglist',
394-
flags: ['auto', 'inout'],
395-
extras: ['all', 'none'],
396-
dflt: 'all',
394+
flags: ['autoscale', 'zoominout'],
395+
extras: ['none'],
396+
dflt: 'none',
397397
editType: 'modebar',
398398
description: [
399-
'Determines which modebar buttons impact this axis.',
400-
'*auto* allows the autoscale buttons, *inout* allows the',
401-
'zoom-in and zoom-out buttons.'
399+
'Disables certain modebar buttons for this axis.',
400+
'*autoscale* disables the autoscale buttons, *zoominout*',
401+
'disables the zoom-in and zoom-out buttons.'
402402
].join(' ')
403403
},
404404
insiderange: {

src/plots/cartesian/layout_defaults.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
338338
});
339339

340340
coerce('fixedrange');
341-
coerce('modebarbuttons');
341+
coerce('modebardisable');
342342

343343
addMissingMatchedAxis();
344344

@@ -367,7 +367,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
367367
}
368368

369369
coerce('fixedrange');
370-
coerce('modebarbuttons');
370+
coerce('modebardisable');
371371
}
372372

373373
for(i = 0; i < yNames.length; i++) {
@@ -380,7 +380,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
380380
var fixedRangeDflt = getComponentMethod('rangeslider', 'isVisible')(anchoredAxis);
381381

382382
coerce('fixedrange', fixedRangeDflt);
383-
coerce('modebarbuttons');
383+
coerce('modebardisable');
384384
}
385385

386386
// Finally, handle scale constraints and matching axes.

test/jasmine/tests/modebar_test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,11 +1194,11 @@ describe('ModeBar', function() {
11941194
assertRange('yaxis2', [0, 4]);
11951195
});
11961196

1197-
it('should respect modebarbuttons attribute', function(done) {
1197+
it('should respect modebardisable attribute', function(done) {
11981198
Plotly.relayout(gd, {
1199-
'xaxis.modebarbuttons': 'none',
1200-
'xaxis2.modebarbuttons': 'auto',
1201-
'yaxis.modebarbuttons': 'inout',
1199+
'xaxis.modebardisable': 'zoominout+autoscale',
1200+
'xaxis2.modebardisable': 'zoominout',
1201+
'yaxis.modebardisable': 'autoscale',
12021202
}).then(function() {
12031203
var buttonZoomIn = selectButton(modeBar, 'zoomIn2d');
12041204
var buttonZoomOut = selectButton(modeBar, 'zoomOut2d');

test/plot-schema.json

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13912,20 +13912,6 @@
1391213912
"allticks"
1391313913
]
1391413914
},
13915-
"modebarbuttons": {
13916-
"description": "Determines which modebar buttons impact this axis. *auto* allows the autoscale buttons, *inout* allows the zoom-in and zoom-out buttons.",
13917-
"dflt": "all",
13918-
"editType": "modebar",
13919-
"extras": [
13920-
"all",
13921-
"none"
13922-
],
13923-
"flags": [
13924-
"auto",
13925-
"inout"
13926-
],
13927-
"valType": "flaglist"
13928-
},
1392913915
"nticks": {
1393013916
"description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.",
1393113917
"dflt": 0,
@@ -15477,20 +15463,6 @@
1547715463
"allticks"
1547815464
]
1547915465
},
15480-
"modebarbuttons": {
15481-
"description": "Determines which modebar buttons impact this axis. *auto* allows the autoscale buttons, *inout* allows the zoom-in and zoom-out buttons.",
15482-
"dflt": "all",
15483-
"editType": "modebar",
15484-
"extras": [
15485-
"all",
15486-
"none"
15487-
],
15488-
"flags": [
15489-
"auto",
15490-
"inout"
15491-
],
15492-
"valType": "flaglist"
15493-
},
1549415466
"nticks": {
1549515467
"description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.",
1549615468
"dflt": 0,

0 commit comments

Comments
 (0)