Skip to content

Commit 95b8c10

Browse files
committed
test turning on autorange via rangeslider attrs
this test fails if rangeslider.yaxis.rangemode or rangeslider.(auto)range doesn't have editType: 'calc'
1 parent 6a88b24 commit 95b8c10

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

src/components/rangeslider/oppaxis_attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = {
3636
{valType: 'any', editType: 'plot'},
3737
{valType: 'any', editType: 'plot'}
3838
],
39-
editType: 'calc',
39+
editType: 'plot',
4040
description: [
4141
'Sets the range of this axis for the rangeslider.'
4242
].join(' ')

test/jasmine/tests/range_slider_test.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,67 @@ describe('rangesliders in general', function() {
911911
.catch(failTest)
912912
.then(done);
913913
});
914+
915+
it('should be able to turn on rangeslider x/y autorange if initially specified', function(done) {
916+
Plotly.plot(gd, [{
917+
// use a heatmap because it doesn't add any padding
918+
x0: 0, dx: 1,
919+
y0: 1, dy: 1,
920+
z: [[1, 2, 3], [2, 3, 4], [3, 4, 5]],
921+
type: 'heatmap'
922+
}], {
923+
xaxis: {
924+
range: [0.1, 1.9],
925+
rangeslider: {range: [0, 2], yaxis: {range: [1, 3]}}
926+
},
927+
yaxis: {range: [1.1, 2.9]}
928+
})
929+
.then(function() {
930+
expect(gd._fullLayout.xaxis.rangeslider.range).toBeCloseToArray([0, 2], 3);
931+
expect(gd._fullLayout.xaxis.rangeslider.yaxis.range).toBeCloseToArray([1, 3], 3);
932+
933+
return Plotly.relayout(gd, {'xaxis.rangeslider.yaxis.rangemode': 'auto'});
934+
})
935+
.then(function() {
936+
expect(gd._fullLayout.xaxis.rangeslider.range).toBeCloseToArray([0, 2], 3);
937+
expect(gd._fullLayout.xaxis.rangeslider.yaxis.range).toBeCloseToArray([0.5, 3.5], 3);
938+
939+
return Plotly.relayout(gd, {'xaxis.rangeslider.autorange': true});
940+
})
941+
.then(function() {
942+
expect(gd._fullLayout.xaxis.rangeslider.range).toBeCloseToArray([-0.5, 2.5], 3);
943+
expect(gd._fullLayout.xaxis.rangeslider.yaxis.range).toBeCloseToArray([0.5, 3.5], 3);
944+
})
945+
.catch(failTest)
946+
.then(done);
947+
});
948+
949+
it('should be able to turn on rangeslider x/y autorange implicitly by deleting x range', function(done) {
950+
// this does not apply to y ranges, because the default there is 'match'
951+
Plotly.plot(gd, [{
952+
// use a heatmap because it doesn't add any padding
953+
x0: 0, dx: 1,
954+
y0: 1, dy: 1,
955+
z: [[1, 2, 3], [2, 3, 4], [3, 4, 5]],
956+
type: 'heatmap'
957+
}], {
958+
xaxis: {
959+
range: [0.1, 1.9],
960+
rangeslider: {range: [0, 2], yaxis: {range: [1, 3]}}
961+
},
962+
yaxis: {range: [1.1, 2.9]}
963+
})
964+
.then(function() {
965+
expect(gd._fullLayout.xaxis.rangeslider.range).toBeCloseToArray([0, 2], 3);
966+
967+
return Plotly.relayout(gd, {'xaxis.rangeslider.range': null});
968+
})
969+
.then(function() {
970+
expect(gd._fullLayout.xaxis.rangeslider.range).toBeCloseToArray([-0.5, 2.5], 3);
971+
})
972+
.catch(failTest)
973+
.then(done);
974+
});
914975
});
915976

916977
function slide(fromX, fromY, toX, toY) {

0 commit comments

Comments
 (0)