Skip to content

Stacked Area Charts #2960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rangemode only applies to linear axes
  • Loading branch information
alexcjohnson committed Sep 1, 2018
commit 0541cd1e3d6822a786ba8bf7da2a35d0ae87457e
13 changes: 8 additions & 5 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ var Titles = require('../../components/titles');
var Color = require('../../components/color');
var Drawing = require('../../components/drawing');

var axAttrs = require('./layout_attributes');

var constants = require('../../constants/numerical');
var ONEAVGYEAR = constants.ONEAVGYEAR;
var ONEAVGMONTH = constants.ONEAVGMONTH;
Expand Down Expand Up @@ -2411,11 +2413,12 @@ function swapAxisGroup(gd, xIds, yIds) {
for(i = 0; i < xIds.length; i++) xFullAxes.push(axes.getFromId(gd, xIds[i]));
for(i = 0; i < yIds.length; i++) yFullAxes.push(axes.getFromId(gd, yIds[i]));

var allAxKeys = Object.keys(xFullAxes[0]),
noSwapAttrs = [
'anchor', 'domain', 'overlaying', 'position', 'side', 'tickangle'
],
numericTypes = ['linear', 'log'];
var allAxKeys = Object.keys(axAttrs);

var noSwapAttrs = [
'anchor', 'domain', 'overlaying', 'position', 'side', 'tickangle', 'editType'
];
var numericTypes = ['linear', 'log'];

for(i = 0; i < allAxKeys.length; i++) {
var keyi = allAxKeys[i],
Expand Down
2 changes: 1 addition & 1 deletion src/plots/cartesian/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
setConvert(containerOut, layoutOut);

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

coerce('range');
containerOut.cleanRange();
Expand Down
3 changes: 2 additions & 1 deletion src/plots/cartesian/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ module.exports = {
'If *tozero*`, the range extends to 0,',
'regardless of the input data',
'If *nonnegative*, the range is non-negative,',
'regardless of the input data.'
'regardless of the input data.',
'Applies only to linear axes.'
].join(' ')
},
range: {
Expand Down
18 changes: 18 additions & 0 deletions test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,24 @@ describe('Test axes', function() {
});
});

it('only allows rangemode with linear axes', function() {
layoutIn = {
xaxis: {type: 'log', rangemode: 'tozero'},
yaxis: {type: 'date', rangemode: 'tozero'},
xaxis2: {type: 'category', rangemode: 'tozero'},
yaxis2: {type: 'linear', rangemode: 'tozero'}
};
layoutOut._subplots.cartesian.push('x2y2');
layoutOut._subplots.yaxis.push('x2', 'y2');

supplyLayoutDefaults(layoutIn, layoutOut, fullData);

expect(layoutOut.xaxis.rangemode).toBeUndefined();
expect(layoutOut.yaxis.rangemode).toBeUndefined();
expect(layoutOut.xaxis2.rangemode).toBeUndefined();
expect(layoutOut.yaxis2.rangemode).toBe('tozero');
});

it('finds scaling groups and calculates relative scales', function() {
layoutIn = {
// first group: linked in series, scales compound
Expand Down