Skip to content

Commit 6a88b24

Browse files
committed
Merge branch 'rangeslider-allow-zoom-on-oppaxis' of github.com:TomDemulierChevret/plotly.js into rangeslider-allow-zoom-on-oppaxis
2 parents ccb6091 + 43f15a7 commit 6a88b24

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

src/components/rangeslider/defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
var Lib = require('../../lib');
1212
var attributes = require('./attributes');
13-
var rangeAttributes = require('./range_attributes');
13+
var oppAxisAttrs = require('./oppaxis_attributes');
1414
var axisIds = require('../../plots/cartesian/axis_ids');
1515

1616
module.exports = function handleDefaults(layoutIn, layoutOut, axName) {
@@ -30,7 +30,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) {
3030
}
3131

3232
function coerceRange(rangeContainerIn, rangeContainerOut, attr, dflt) {
33-
return Lib.coerce(rangeContainerIn, rangeContainerOut, rangeAttributes, attr, dflt);
33+
return Lib.coerce(rangeContainerIn, rangeContainerOut, oppAxisAttrs, attr, dflt);
3434
}
3535

3636
var visible = coerce('visible');

src/components/rangeslider/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@
88

99
'use strict';
1010

11+
var Lib = require('../../lib');
12+
var attrs = require('./attributes');
13+
var oppAxisAttrs = require('./oppaxis_attributes');
14+
1115
module.exports = {
1216
moduleType: 'component',
1317
name: 'rangeslider',
1418

1519
schema: {
1620
subplots: {
17-
xaxis: {rangeslider: require('./attributes')}
21+
xaxis: {
22+
rangeslider: Lib.extendFlat({}, attrs, {
23+
yaxis: oppAxisAttrs
24+
})
25+
}
1826
}
1927
},
2028

src/components/rangeslider/range_attributes.js renamed to src/components/rangeslider/oppaxis_attributes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
'use strict';
1010

1111
module.exports = {
12+
// not really a 'subplot' attribute container,
13+
// but this is the flag we use to denote attributes that
14+
// support yaxis, yaxis2, yaxis3, ... counters
15+
_isSubplotObj: true,
16+
1217
rangemode: {
1318
valType: 'enumerated',
1419
values: ['auto', 'fixed', 'match'],

test/jasmine/tests/plotschema_test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,15 @@ describe('plot schema', function() {
126126
});
127127

128128
it('all subplot objects should contain _isSubplotObj', function() {
129-
var IS_SUBPLOT_OBJ = '_isSubplotObj',
130-
astrs = ['xaxis', 'yaxis', 'scene', 'geo', 'ternary', 'mapbox', 'polar'],
131-
cnt = 0;
129+
var IS_SUBPLOT_OBJ = '_isSubplotObj';
130+
var cnt = 0;
131+
132+
var astrs = [
133+
'xaxis', 'yaxis', 'scene', 'geo', 'ternary', 'mapbox', 'polar',
134+
// not really a 'subplot' object but supports yaxis, yaxis2, yaxis3,
135+
// ... counters, so list it here
136+
'xaxis.rangeslider.yaxis'
137+
];
132138

133139
// check if the subplot objects have '_isSubplotObj'
134140
astrs.forEach(function(astr) {

test/jasmine/tests/validate_test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,4 +505,25 @@ describe('Plotly.validate', function() {
505505
'In layout, key grid.subplots[2][0] is set to an invalid value (5)'
506506
);
507507
});
508+
509+
it('should detect opposite axis range slider attributes', function() {
510+
var out = Plotly.validate([
511+
{y: [1, 2]},
512+
{y: [1, 2], yaxis: 'y2'},
513+
{y: [1, 2], yaxis: 'y3'}
514+
], {
515+
xaxis: {
516+
rangeslider: {
517+
yaxis: { rangemode: 'auto' },
518+
yaxis2: { rangemode: 'fixed' },
519+
yaxis3: { range: [0, 1] }
520+
}
521+
},
522+
yaxis: {},
523+
yaxis2: {},
524+
yaxis3: {}
525+
});
526+
527+
expect(out).toBeUndefined();
528+
});
508529
});

0 commit comments

Comments
 (0)