Skip to content

Commit d787b9f

Browse files
committed
revise attributes
1 parent 4d891b3 commit d787b9f

21 files changed

+484
-423
lines changed

src/plots/cartesian/autorange.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -631,34 +631,38 @@ function greaterOrEqual(v0, v1) { return v0 >= v1; }
631631

632632
function applyAutorangeMinOptions(v, ax) {
633633
if(
634-
ax.autorangemin !== undefined &&
635-
hasValidMinAndMax(ax, ax.autorangemin, ax.autorangemax)
634+
ax.autorangeoptions &&
635+
ax.autorangeoptions.minallowed !== undefined &&
636+
hasValidMinAndMax(ax, ax.autorangeoptions.minallowed, ax.autorangeoptions.maxallowed)
636637
) {
637-
return ax.autorangemin;
638+
return ax.autorangeoptions.minallowed;
638639
}
639640

640641
if(
641-
ax.autorangeclipmin !== undefined &&
642-
hasValidMinAndMax(ax, ax.autorangeclipmin, ax.autorangeclipmax)
642+
ax.autorangeoptions &&
643+
ax.autorangeoptions.clipmin !== undefined &&
644+
hasValidMinAndMax(ax, ax.autorangeoptions.clipmin, ax.autorangeoptions.clipmax)
643645
) {
644-
return Math.max(v, ax.d2l(ax.autorangeclipmin));
646+
return Math.max(v, ax.d2l(ax.autorangeoptions.clipmin));
645647
}
646648
return v;
647649
}
648650

649651
function applyAutorangeMaxOptions(v, ax) {
650652
if(
651-
ax.autorangemax !== undefined &&
652-
hasValidMinAndMax(ax, ax.autorangemin, ax.autorangemax)
653+
ax.autorangeoptions &&
654+
ax.autorangeoptions.maxallowed !== undefined &&
655+
hasValidMinAndMax(ax, ax.autorangeoptions.minallowed, ax.autorangeoptions.maxallowed)
653656
) {
654-
return ax.autorangemax;
657+
return ax.autorangeoptions.maxallowed;
655658
}
656659

657660
if(
658-
ax.autorangeclipmax !== undefined &&
659-
hasValidMinAndMax(ax, ax.autorangeclipmin, ax.autorangeclipmax)
661+
ax.autorangeoptions &&
662+
ax.autorangeoptions.clipmax !== undefined &&
663+
hasValidMinAndMax(ax, ax.autorangeoptions.clipmin, ax.autorangeoptions.clipmax)
660664
) {
661-
return Math.min(v, ax.d2l(ax.autorangeclipmax));
665+
return Math.min(v, ax.d2l(ax.autorangeoptions.clipmax));
662666
}
663667
return v;
664668
}
@@ -669,8 +673,8 @@ function hasValidMinAndMax(ax, min, max) {
669673
min !== undefined &&
670674
max !== undefined
671675
) {
672-
min = ax.d2l(ax.autorangeclipmin);
673-
max = ax.d2l(ax.autorangeclipmax);
676+
min = ax.d2l(ax.autorangeoptions.clipmin);
677+
max = ax.d2l(ax.autorangeoptions.clipmax);
674678
return min < max;
675679
}
676680
return true;
@@ -679,12 +683,12 @@ function hasValidMinAndMax(ax, min, max) {
679683
// this function should be (and is) called before reversing the range
680684
// so range[0] is the minimum and range[1] is the maximum
681685
function applyAutorangeOptions(range, ax) {
682-
if(!ax) return range;
686+
if(!ax || !ax.autorangeoptions) return range;
683687

684688
var min = range[0];
685689
var max = range[1];
686690

687-
var include = ax.autorangeinclude;
691+
var include = ax.autorangeoptions.include;
688692
if(include !== undefined) {
689693
var lMin = ax.d2l(min);
690694
var lMax = ax.d2l(max);
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict';
22

33
module.exports = function handleAutorangeOptionsDefaults(coerce) {
4-
var autorangemin = coerce('autorangemin');
5-
var autorangemax = coerce('autorangemax');
4+
var minallowed = coerce('autorangeoptions.minallowed');
5+
var maxallowed = coerce('autorangeoptions.maxallowed');
66

7-
if(autorangemin === undefined) coerce('autorangeclipmin');
8-
if(autorangemax === undefined) coerce('autorangeclipmax');
7+
if(minallowed === undefined) coerce('autorangeoptions.clipmin');
8+
if(maxallowed === undefined) coerce('autorangeoptions.clipmax');
99

10-
coerce('autorangeinclude');
10+
coerce('autorangeoptions.include');
1111
};

src/plots/cartesian/axis_defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
101101
if(axType === 'linear' || axType === '-') coerce('rangemode');
102102
}
103103

104-
coerce('rangemin');
105-
coerce('rangemax');
104+
coerce('minallowed');
105+
coerce('maxallowed');
106106
coerce('range');
107107
containerOut.cleanRange();
108108

src/plots/cartesian/dragbox.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
924924
}
925925

926926
if(xScaleFactor2 > 1 && (
927-
(xa.rangemax !== undefined && editX === (xa.range[0] < xa.range[1] ? 'e' : 'w')) ||
928-
(xa.rangemin !== undefined && editX === (xa.range[0] < xa.range[1] ? 'w' : 'e'))
927+
(xa.maxallowed !== undefined && editX === (xa.range[0] < xa.range[1] ? 'e' : 'w')) ||
928+
(xa.minallowed !== undefined && editX === (xa.range[0] < xa.range[1] ? 'w' : 'e'))
929929
)) {
930930
xScaleFactor2 = 1;
931931
clipDx = 0;
@@ -948,8 +948,8 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
948948
}
949949

950950
if(yScaleFactor2 > 1 && (
951-
(ya.rangemax !== undefined && editY === (ya.range[0] < ya.range[1] ? 'n' : 's')) ||
952-
(ya.rangemin !== undefined && editY === (ya.range[0] < ya.range[1] ? 's' : 'n'))
951+
(ya.maxallowed !== undefined && editY === (ya.range[0] < ya.range[1] ? 'n' : 's')) ||
952+
(ya.minallowed !== undefined && editY === (ya.range[0] < ya.range[1] ? 's' : 'n'))
953953
)) {
954954
yScaleFactor2 = 1;
955955
clipDy = 0;

src/plots/cartesian/layout_attributes.js

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -283,48 +283,51 @@ module.exports = {
283283
'If `range` is provided, then `autorange` is set to *false*.'
284284
].join(' ')
285285
},
286-
autorangemin: {
287-
valType: 'any',
288-
editType: 'plot',
289-
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
290-
description: [
291-
'Use this value exactly as autorange minimum.'
292-
].join(' ')
293-
},
294-
autorangemax: {
295-
valType: 'any',
296-
editType: 'plot',
297-
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
298-
description: [
299-
'Use this value exactly as autorange maximum.'
300-
].join(' ')
301-
},
302-
autorangeclipmin: {
303-
valType: 'any',
304-
editType: 'plot',
305-
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
306-
description: [
307-
'Clip autorange minimum if it goes beyond this value.',
308-
'Has no effect when `autorangemin` is provided.'
309-
].join(' ')
310-
},
311-
autorangeclipmax: {
312-
valType: 'any',
313-
editType: 'plot',
314-
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
315-
description: [
316-
'Clip autorange maximum if it goes beyond this value.',
317-
'Has no effect when `autorangemax` is provided.'
318-
].join(' ')
319-
},
320-
autorangeinclude: {
321-
valType: 'any',
322-
arrayOk: true,
323-
editType: 'plot',
324-
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
325-
description: [
326-
'Ensure this value is included in autorange.'
327-
].join(' ')
286+
autorangeoptions: {
287+
minallowed: {
288+
valType: 'any',
289+
editType: 'plot',
290+
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
291+
description: [
292+
'Use this value exactly as autorange minimum.'
293+
].join(' ')
294+
},
295+
maxallowed: {
296+
valType: 'any',
297+
editType: 'plot',
298+
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
299+
description: [
300+
'Use this value exactly as autorange maximum.'
301+
].join(' ')
302+
},
303+
clipmin: {
304+
valType: 'any',
305+
editType: 'plot',
306+
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
307+
description: [
308+
'Clip autorange minimum if it goes beyond this value.',
309+
'Has no effect when `autorangeoptions.minallowed` is provided.'
310+
].join(' ')
311+
},
312+
clipmax: {
313+
valType: 'any',
314+
editType: 'plot',
315+
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
316+
description: [
317+
'Clip autorange maximum if it goes beyond this value.',
318+
'Has no effect when `autorangeoptions.maxallowed` is provided.'
319+
].join(' ')
320+
},
321+
include: {
322+
valType: 'any',
323+
arrayOk: true,
324+
editType: 'plot',
325+
impliedEdits: {'range[0]': undefined, 'range[1]': undefined},
326+
description: [
327+
'Ensure this value is included in autorange.'
328+
].join(' ')
329+
},
330+
editType: 'plot'
328331
},
329332
rangemode: {
330333
valType: 'enumerated',
@@ -363,15 +366,15 @@ module.exports = {
363366
'number from zero in the order it appears.'
364367
].join(' ')
365368
},
366-
rangemin: {
369+
minallowed: {
367370
valType: 'any',
368371
editType: 'plot',
369372
impliedEdits: {'^autorange': false},
370373
description: [
371374
'Determines the minimum range of this axis.'
372375
].join(' ')
373376
},
374-
rangemax: {
377+
maxallowed: {
375378
valType: 'any',
376379
editType: 'plot',
377380
impliedEdits: {'^autorange': false},

src/plots/cartesian/set_convert.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,20 +433,20 @@ module.exports = function setConvert(ax, fullLayout) {
433433
};
434434

435435
ax.limitRange = function(rangeAttr) {
436-
var rangemin = ax.rangemin;
437-
var rangemax = ax.rangemax;
438-
if(rangemin === undefined && rangemax === undefined) return;
436+
var minallowed = ax.minallowed;
437+
var maxallowed = ax.maxallowed;
438+
if(minallowed === undefined && maxallowed === undefined) return;
439439

440440
if(!rangeAttr) rangeAttr = 'range';
441441
var range = Lib.nestedProperty(ax, rangeAttr).get();
442442
var rng = Lib.simpleMap(range, ax.r2l);
443443
var axrev = rng[1] < rng[0];
444444
if(axrev) rng.reverse();
445445

446-
var bounds = Lib.simpleMap([rangemin, rangemax], ax.r2l);
446+
var bounds = Lib.simpleMap([minallowed, maxallowed], ax.r2l);
447447

448-
if(rangemin !== undefined && rng[0] < bounds[0]) range[axrev ? 1 : 0] = rangemin;
449-
if(rangemax !== undefined && rng[1] > bounds[1]) range[axrev ? 0 : 1] = rangemax;
448+
if(minallowed !== undefined && rng[0] < bounds[0]) range[axrev ? 1 : 0] = minallowed;
449+
if(maxallowed !== undefined && rng[1] > bounds[1]) range[axrev ? 0 : 1] = maxallowed;
450450
};
451451

452452
/*

src/plots/gl3d/layout/axis_attributes.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,17 @@ module.exports = overrideAll({
6565
}),
6666
autotypenumbers: axesAttrs.autotypenumbers,
6767
autorange: axesAttrs.autorange,
68-
autorangemin: axesAttrs.autorangemin,
69-
autorangemax: axesAttrs.autorangemax,
70-
autorangeclipmin: axesAttrs.autorangeclipmin,
71-
autorangeclipmax: axesAttrs.autorangeclipmax,
72-
autorangeinclude: axesAttrs.autorangeinclude,
68+
autorangeoptions: {
69+
minallowed: axesAttrs.autorangeoptions.minallowed,
70+
maxallowed: axesAttrs.autorangeoptions.maxallowed,
71+
clipmin: axesAttrs.autorangeoptions.clipmin,
72+
clipmax: axesAttrs.autorangeoptions.clipmax,
73+
include: axesAttrs.autorangeoptions.include,
74+
editType: 'plot'
75+
},
7376
rangemode: axesAttrs.rangemode,
74-
rangemin: axesAttrs.rangemin,
75-
rangemax: axesAttrs.rangemax,
77+
minallowed: axesAttrs.minallowed,
78+
maxallowed: axesAttrs.maxallowed,
7679
range: extendFlat({}, axesAttrs.range, {
7780
items: [
7881
{valType: 'any', editType: 'plot', impliedEdits: {'^autorange': false}},

src/plots/polar/layout_attributes.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@ var radialAxisAttrs = {
5858
}),
5959
autotypenumbers: axesAttrs.autotypenumbers,
6060

61-
autorangemin: axesAttrs.autorangemin,
62-
autorangemax: axesAttrs.autorangemax,
63-
autorangeclipmin: axesAttrs.autorangeclipmin,
64-
autorangeclipmax: axesAttrs.autorangeclipmax,
65-
autorangeinclude: axesAttrs.autorangeinclude,
61+
autorangeoptions: {
62+
minallowed: axesAttrs.autorangeoptions.minallowed,
63+
maxallowed: axesAttrs.autorangeoptions.maxallowed,
64+
clipmin: axesAttrs.autorangeoptions.clipmin,
65+
clipmax: axesAttrs.autorangeoptions.clipmax,
66+
include: axesAttrs.autorangeoptions.include,
67+
editType: 'plot'
68+
},
6669
autorange: extendFlat({}, axesAttrs.autorange, {editType: 'plot'}),
6770
rangemode: {
6871
valType: 'enumerated',
@@ -78,8 +81,8 @@ var radialAxisAttrs = {
7881
'of the input data (same behavior as for cartesian axes).'
7982
].join(' ')
8083
},
81-
rangemin: extendFlat({}, axesAttrs.rangemin, {editType: 'plot'}),
82-
rangemax: extendFlat({}, axesAttrs.rangemax, {editType: 'plot'}),
84+
minallowed: extendFlat({}, axesAttrs.minallowed, {editType: 'plot'}),
85+
maxallowed: extendFlat({}, axesAttrs.maxallowed, {editType: 'plot'}),
8386
range: extendFlat({}, axesAttrs.range, {
8487
items: [
8588
{valType: 'any', editType: 'plot', impliedEdits: {'^autorange': false}},

src/plots/polar/layout_defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ function handleDefaults(contIn, contOut, coerce, opts) {
8686
if(autoRange === 'reversed') axOut._m = -1;
8787
}
8888

89-
coerceAxis('rangemin');
90-
coerceAxis('rangemax');
89+
coerceAxis('minallowed');
90+
coerceAxis('maxallowed');
9191
coerceAxis('range');
9292
axOut.cleanRange('range', {dfltRange: [0, 1]});
9393
break;

test/image/mocks/axes_labels.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@
5353
],
5454
"layout": {
5555
"xaxis": {
56-
"autorangeclipmin": 0.5,
57-
"autorangeclipmax": 7.5,
56+
"autorangeoptions": {
57+
"clipmin": 0.5,
58+
"clipmax": 7.5
59+
},
5860
"tickfont": {
5961
"color": "black",
6062
"family": "Old Standard TT, serif",
@@ -74,8 +76,10 @@
7476
"exponentformat": "e"
7577
},
7678
"yaxis": {
77-
"autorangeclipmin": "5e-1",
78-
"autorangeclipmax": "7.5",
79+
"autorangeoptions": {
80+
"clipmin": "5e-1",
81+
"clipmax": "7.5"
82+
},
7983
"tickfont": {
8084
"color": "black",
8185
"family": "Old Standard TT, serif",

0 commit comments

Comments
 (0)