Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions draftlogs/7967_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix range slider drawing spurious grey bands on initial render when `rangeslider.yaxis.rangemode` is `"fixed"` and the counter axis is autoranged [[#7967](https://github.com/plotly/plotly.js/pull/7967)]
4 changes: 4 additions & 0 deletions src/components/rangeslider/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) {
var rangeMode = coerceRange('rangemode', rangemodeDflt);
if(rangeMode !== 'match') {
coerceRange('range', yAxOut.range.slice());

if(rangeMode === 'fixed' && !rangemodeDflt && yAxOut.autorange) {
rangeContainerOut._rangeDfltFromAutorangedAx = true;
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/plots/cartesian/autorange.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,9 @@ function doAutoRange(gd, ax, presetRange) {
if(anchorAx && anchorAx.rangeslider) {
var axeRangeOpts = anchorAx.rangeslider[ax._name];
if(axeRangeOpts) {
if(axeRangeOpts.rangemode === 'auto') {
if(axeRangeOpts.rangemode === 'auto' || axeRangeOpts._rangeDfltFromAutorangedAx) {
axeRangeOpts.range = getAutoRange(gd, ax);
delete axeRangeOpts._rangeDfltFromAutorangedAx;
}
}
anchorAx._input.rangeslider[ax._name] = Lib.extendFlat({}, axeRangeOpts);
Expand Down
24 changes: 24 additions & 0 deletions test/jasmine/tests/range_slider_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,30 @@ describe('rangesliders in general', function() {
.then(done, done.fail);
});

it('should not leave "fixed" rangemode on the placeholder range of an autoranged counter axis', function(done) {
Plotly.newPlot(gd, [{
// use a heatmap because it doesn't add any padding
x0: 0, dx: 1,
y0: 1, dy: 1,
z: [[1, 2, 3], [2, 3, 4], [3, 4, 5]],
type: 'heatmap'
}], {
xaxis: {
rangeslider: {visible: true, yaxis: {rangemode: 'fixed'}}
}
})
.then(function() {
expect(gd._fullLayout.yaxis.range).toBeCloseToArray([0.5, 3.5], 3);
expect(gd._fullLayout.xaxis.rangeslider.yaxis.range).toBeCloseToArray([0.5, 3.5], 3);
return Plotly.restyle(gd, {dy: 4});
})
.then(function() {
expect(gd._fullLayout.yaxis.range).toBeCloseToArray([-1, 11], 3);
expect(gd._fullLayout.xaxis.rangeslider.yaxis.range).toBeCloseToArray([0.5, 3.5], 3);
})
.then(done, done.fail);
});

it('should be able to turn on rangeslider x/y autorange implicitly by deleting x range', function(done) {
// this does not apply to y ranges, because the default there is 'match'
Plotly.newPlot(gd, [{
Expand Down