Skip to content

Commit 43f15a7

Browse files
committed
add rangeslider.yaxis? to schema flagging it with _isSubplotObj
1 parent c556f8c commit 43f15a7

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

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/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)