Skip to content

Commit 0ae2831

Browse files
Change yAxis rangeslider rangeOpts computation + fix yAxis rangeslider rangeOpts used to draw the trace
1 parent a8a3ee5 commit 0ae2831

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/components/rangeslider/draw.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ module.exports = function(gd) {
152152
rangeSlider
153153
.call(drawBg, gd, axisOpts, opts)
154154
.call(addClipPath, gd, axisOpts, opts)
155-
.call(drawRangePlot, gd, axisOpts, opts, oppAxisRangeOpts)
155+
.call(drawRangePlot, gd, axisOpts, opts)
156156
.call(drawMasks, gd, axisOpts, opts, oppAxisRangeOpts)
157157
.call(drawSlideBox, gd, axisOpts, opts)
158158
.call(drawGrabbers, gd, axisOpts, opts);
@@ -386,7 +386,7 @@ function addClipPath(rangeSlider, gd, axisOpts, opts) {
386386
});
387387
}
388388

389-
function drawRangePlot(rangeSlider, gd, axisOpts, opts, oppAxisRangeOpts) {
389+
function drawRangePlot(rangeSlider, gd, axisOpts, opts) {
390390
var subplotData = Axes.getSubplots(gd, axisOpts),
391391
calcData = gd.calcdata;
392392

@@ -408,7 +408,8 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts, oppAxisRangeOpts) {
408408
isMainPlot = (i === 0);
409409

410410
var oppAxisOpts = Axes.getFromId(gd, id, 'y'),
411-
oppAxisName = oppAxisOpts._name;
411+
oppAxisName = oppAxisOpts._name,
412+
oppAxisRangeOpts = opts[oppAxisName];
412413

413414
var mockFigure = {
414415
data: [],
@@ -429,7 +430,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts, oppAxisRangeOpts) {
429430
mockFigure.layout[oppAxisName] = {
430431
type: oppAxisOpts.type,
431432
domain: [0, 1],
432-
range: (oppAxisRangeOpts.rangemode === 'auto' || oppAxisRangeOpts.rangemode === 'fixed') ? oppAxisRangeOpts.range.slice() : oppAxisOpts.range.slice(),
433+
range: oppAxisRangeOpts.range.slice(),
433434
calendar: oppAxisOpts.calendar
434435
};
435436

src/plots/cartesian/axes.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,22 @@ axes.doAutoRange = function(ax) {
368368
axIn.autorange = ax.autorange;
369369
}
370370

371-
if(ax.rangeslider) {
372-
var anchorAxis = ax._anchorAxis;
373-
if(ax.rangeslider[anchorAxis._name] && ax.rangeslider[anchorAxis._name].rangemode === 'auto') {
374-
hasDeps = (anchorAxis._min && anchorAxis._max && anchorAxis._min.length && anchorAxis._max.length);
375-
ax.rangeslider[anchorAxis._name].range = hasDeps ? axes.getAutoRange(anchorAxis) : anchorAxis.range.slice();
376-
axIn = ax._input;
377-
axIn.rangeslider[anchorAxis._name].range = ax.rangeslider[anchorAxis._name].range.slice();
378-
axIn.rangeslider[anchorAxis._name].rangemode = ax.rangeslider[anchorAxis._name].rangemode;
371+
if(ax._anchorAxis && ax._anchorAxis.rangeslider) {
372+
var axeRangeOpts = ax._anchorAxis.rangeslider[ax._name];
373+
switch(axeRangeOpts.rangemode) {
374+
case 'auto':
375+
axeRangeOpts.range = hasDeps ? axes.getAutoRange(ax) : ax.range.slice();
376+
break;
377+
case 'match':
378+
axeRangeOpts.range = ax.range.slice();
379+
break;
380+
default:
381+
axeRangeOpts.range = ax.range.slice();
382+
break;
379383
}
384+
axIn = ax._anchorAxis._input;
385+
axIn.rangeslider[ax._name].range = axeRangeOpts.range.slice();
386+
axIn.rangeslider[ax._name].rangemode = axeRangeOpts.rangemode;
380387
}
381388
};
382389

0 commit comments

Comments
 (0)