Skip to content

Commit bc2a40a

Browse files
Switch to new rangeslider range opts (default missing)
1 parent 32488f1 commit bc2a40a

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

src/components/rangeslider/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
// style constants
3838

3939
maskColor: 'rgba(0,0,0,0.4)',
40-
maskOppColor: 'rgba(0,0,0,0.2)',
40+
maskOppAxisColor: 'rgba(0,0,0,0.2)',
4141

4242
slideBoxFill: 'transparent',
4343
slideBoxCursor: 'ew-resize',

src/components/rangeslider/defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) {
3737

3838
coerce('autorange', !axOut.isValidRange(containerIn.range));
3939
coerce('range');
40+
containerOut.yaxis = containerIn.yaxis;
4041

4142
// to map back range slider (auto) range
4243
containerOut._input = containerIn;

src/components/rangeslider/draw.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ module.exports = function(gd) {
7878
rangeSliders.each(function(axisOpts) {
7979
var rangeSlider = d3.select(this),
8080
opts = axisOpts[constants.name],
81-
oppAxisOpts = fullLayout[Axes.id2name(axisOpts.anchor)];
81+
oppAxisOpts = fullLayout[Axes.id2name(axisOpts.anchor)],
82+
oppAxisRangeOpts = opts[Axes.id2name(axisOpts.anchor)];
8283

8384
// update range
8485
// Expand slider range to the axis range
@@ -136,9 +137,9 @@ module.exports = function(gd) {
136137

137138
opts._rl = [range0, range1];
138139

139-
if(oppAxisOpts.rangeslidermode === 'auto' || oppAxisOpts.rangeslidermode === 'fixed') {
140-
var range0OppAxis = oppAxisOpts.r2l(oppAxisOpts.rangesliderrange[0]),
141-
range1OppAxis = oppAxisOpts.r2l(oppAxisOpts.rangesliderrange[1]),
140+
if(oppAxisRangeOpts.rangemode === 'auto' || oppAxisRangeOpts.rangemode === 'fixed') {
141+
var range0OppAxis = oppAxisOpts.r2l(oppAxisRangeOpts.range[0]),
142+
range1OppAxis = oppAxisOpts.r2l(oppAxisRangeOpts.range[1]),
142143
distOppAxis = range1OppAxis - range0OppAxis;
143144

144145
opts.d2pOppAxis = function(v) {
@@ -151,16 +152,16 @@ module.exports = function(gd) {
151152
rangeSlider
152153
.call(drawBg, gd, axisOpts, opts)
153154
.call(addClipPath, gd, axisOpts, opts)
154-
.call(drawRangePlot, gd, axisOpts, opts)
155-
.call(drawMasks, gd, axisOpts, opts, oppAxisOpts)
155+
.call(drawRangePlot, gd, axisOpts, opts, oppAxisRangeOpts)
156+
.call(drawMasks, gd, axisOpts, opts, oppAxisRangeOpts)
156157
.call(drawSlideBox, gd, axisOpts, opts)
157158
.call(drawGrabbers, gd, axisOpts, opts);
158159

159160
// setup drag element
160161
setupDragElement(rangeSlider, gd, axisOpts, opts);
161162

162163
// update current range
163-
setPixelRange(rangeSlider, gd, axisOpts, opts, oppAxisOpts);
164+
setPixelRange(rangeSlider, gd, axisOpts, opts, oppAxisOpts, oppAxisRangeOpts);
164165

165166
// update margins
166167

@@ -276,7 +277,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) {
276277
});
277278
}
278279

279-
function setPixelRange(rangeSlider, gd, axisOpts, opts, oppAxisOpts) {
280+
function setPixelRange(rangeSlider, gd, axisOpts, opts, oppAxisOpts, oppAxisRangeOpts) {
280281
var hw2 = constants.handleWidth / 2;
281282

282283
function clamp(v) {
@@ -305,7 +306,7 @@ function setPixelRange(rangeSlider, gd, axisOpts, opts, oppAxisOpts) {
305306
.attr('x', pixelMax)
306307
.attr('width', opts._width - pixelMax);
307308

308-
if(oppAxisOpts.rangeslidermode === 'auto' || oppAxisOpts.rangeslidermode === 'fixed') {
309+
if(oppAxisRangeOpts.rangemode === 'auto' || oppAxisRangeOpts.rangemode === 'fixed') {
309310
var pixelMinOppAxis = opts._height - clampOppAxis(opts.d2pOppAxis(oppAxisOpts._rl[1])),
310311
pixelMaxOppAxis = opts._height - clampOppAxis(opts.d2pOppAxis(oppAxisOpts._rl[0]));
311312

@@ -385,7 +386,7 @@ function addClipPath(rangeSlider, gd, axisOpts, opts) {
385386
});
386387
}
387388

388-
function drawRangePlot(rangeSlider, gd, axisOpts, opts) {
389+
function drawRangePlot(rangeSlider, gd, axisOpts, opts, oppAxisRangeOpts) {
389390
var subplotData = Axes.getSubplots(gd, axisOpts),
390391
calcData = gd.calcdata;
391392

@@ -428,7 +429,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) {
428429
mockFigure.layout[oppAxisName] = {
429430
type: oppAxisOpts.type,
430431
domain: [0, 1],
431-
range: (oppAxisOpts.rangeslidermode === 'auto' || oppAxisOpts.rangeslidermode === 'fixed') ? oppAxisOpts.rangesliderrange.slice() : oppAxisOpts.range.slice(),
432+
range: (oppAxisRangeOpts.rangemode === 'auto' || oppAxisRangeOpts.rangemode === 'fixed') ? oppAxisRangeOpts.range.slice() : oppAxisOpts.range.slice(),
432433
calendar: oppAxisOpts.calendar
433434
};
434435

@@ -469,7 +470,7 @@ function filterRangePlotCalcData(calcData, subplotId) {
469470
return out;
470471
}
471472

472-
function drawMasks(rangeSlider, gd, axisOpts, opts, oppAxisOpts) {
473+
function drawMasks(rangeSlider, gd, axisOpts, opts, yAxisOpts) {
473474
var maskMin = rangeSlider.selectAll('rect.' + constants.maskMinClassName)
474475
.data([0]);
475476

@@ -495,7 +496,7 @@ function drawMasks(rangeSlider, gd, axisOpts, opts, oppAxisOpts) {
495496
.call(Color.fill, constants.maskColor);
496497

497498
// masks used for oppAxis zoom
498-
if(oppAxisOpts.rangeslidermode === 'auto' || oppAxisOpts.rangeslidermode === 'fixed') {
499+
if(yAxisOpts.rangemode === 'auto' || yAxisOpts.rangemode === 'fixed') {
499500
var maskMinOppAxis = rangeSlider.selectAll('rect.' + constants.maskMinOppAxisClassName)
500501
.data([0]);
501502

@@ -506,7 +507,7 @@ function drawMasks(rangeSlider, gd, axisOpts, opts, oppAxisOpts) {
506507

507508
maskMinOppAxis
508509
.attr('width', opts._width)
509-
.call(Color.fill, constants.maskOppColor);
510+
.call(Color.fill, constants.maskOppAxisColor);
510511

511512
var maskMaxOppAxis = rangeSlider.selectAll('rect.' + constants.maskMaxOppAxisClassName)
512513
.data([0]);
@@ -519,7 +520,7 @@ function drawMasks(rangeSlider, gd, axisOpts, opts, oppAxisOpts) {
519520
maskMaxOppAxis
520521
.attr('width', opts._width)
521522
.style('border-top', constants.maskOppBorder)
522-
.call(Color.fill, constants.maskOppColor);
523+
.call(Color.fill, constants.maskOppAxisColor);
523524
}
524525
}
525526

src/plots/cartesian/axis_defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
5555
containerOut.cleanRange();
5656

5757
if(letter === 'y') {
58-
if(containerIn.rangesliderrange) {
58+
if(!containerIn.rangesliderrange) {
5959
coerce('rangeslidermode', 'auto');
6060
} else if(containerOut.isValidRange(containerIn.rangesliderrange)) {
6161
coerce('rangeslidermode', 'fixed');

0 commit comments

Comments
 (0)