Skip to content

Commit 0541cd1

Browse files
committed
rangemode only applies to linear axes
1 parent 1f4898c commit 0541cd1

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

src/plots/cartesian/axes.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ var Titles = require('../../components/titles');
2020
var Color = require('../../components/color');
2121
var Drawing = require('../../components/drawing');
2222

23+
var axAttrs = require('./layout_attributes');
24+
2325
var constants = require('../../constants/numerical');
2426
var ONEAVGYEAR = constants.ONEAVGYEAR;
2527
var ONEAVGMONTH = constants.ONEAVGMONTH;
@@ -2411,11 +2413,12 @@ function swapAxisGroup(gd, xIds, yIds) {
24112413
for(i = 0; i < xIds.length; i++) xFullAxes.push(axes.getFromId(gd, xIds[i]));
24122414
for(i = 0; i < yIds.length; i++) yFullAxes.push(axes.getFromId(gd, yIds[i]));
24132415

2414-
var allAxKeys = Object.keys(xFullAxes[0]),
2415-
noSwapAttrs = [
2416-
'anchor', 'domain', 'overlaying', 'position', 'side', 'tickangle'
2417-
],
2418-
numericTypes = ['linear', 'log'];
2416+
var allAxKeys = Object.keys(axAttrs);
2417+
2418+
var noSwapAttrs = [
2419+
'anchor', 'domain', 'overlaying', 'position', 'side', 'tickangle', 'editType'
2420+
];
2421+
var numericTypes = ['linear', 'log'];
24192422

24202423
for(i = 0; i < allAxKeys.length; i++) {
24212424
var keyi = allAxKeys[i],

src/plots/cartesian/axis_defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
4848
setConvert(containerOut, layoutOut);
4949

5050
var autoRange = coerce('autorange', !containerOut.isValidRange(containerIn.range));
51-
if(autoRange) coerce('rangemode');
51+
if(autoRange && (axType === 'linear' || axType === '-')) coerce('rangemode');
5252

5353
coerce('range');
5454
containerOut.cleanRange();

src/plots/cartesian/layout_attributes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ module.exports = {
9999
'If *tozero*`, the range extends to 0,',
100100
'regardless of the input data',
101101
'If *nonnegative*, the range is non-negative,',
102-
'regardless of the input data.'
102+
'regardless of the input data.',
103+
'Applies only to linear axes.'
103104
].join(' ')
104105
},
105106
range: {

test/jasmine/tests/axes_test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,24 @@ describe('Test axes', function() {
403403
});
404404
});
405405

406+
it('only allows rangemode with linear axes', function() {
407+
layoutIn = {
408+
xaxis: {type: 'log', rangemode: 'tozero'},
409+
yaxis: {type: 'date', rangemode: 'tozero'},
410+
xaxis2: {type: 'category', rangemode: 'tozero'},
411+
yaxis2: {type: 'linear', rangemode: 'tozero'}
412+
};
413+
layoutOut._subplots.cartesian.push('x2y2');
414+
layoutOut._subplots.yaxis.push('x2', 'y2');
415+
416+
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
417+
418+
expect(layoutOut.xaxis.rangemode).toBeUndefined();
419+
expect(layoutOut.yaxis.rangemode).toBeUndefined();
420+
expect(layoutOut.xaxis2.rangemode).toBeUndefined();
421+
expect(layoutOut.yaxis2.rangemode).toBe('tozero');
422+
});
423+
406424
it('finds scaling groups and calculates relative scales', function() {
407425
layoutIn = {
408426
// first group: linked in series, scales compound

0 commit comments

Comments
 (0)