Skip to content

Rangeslider allow zoom on oppaxis #2364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
519e1a7
better visual cue of zoom on oppaxis with rangeslider
TomDemulierChevret Feb 14, 2018
044e633
add a new attributes to rangeslider to switch back to the old behaviour
TomDemulierChevret Feb 16, 2018
f335258
fix check when using new data
TomDemulierChevret Feb 16, 2018
707f432
fix default value rangeslider test
TomDemulierChevret Feb 16, 2018
6a7f652
renammed new attributes to "fixedyrange"
TomDemulierChevret Feb 16, 2018
fc4f082
Introduce new attributes to axes to allow to specifiy fixed range to …
TomDemulierChevret Feb 19, 2018
92c6550
Fix broken test from attribute removal
TomDemulierChevret Feb 19, 2018
b30167c
Add missing gl attribute
TomDemulierChevret Feb 19, 2018
91caff1
Merge branch 'master' into rangeslider-allow-zoom-on-oppaxis
TomDemulierChevret Feb 19, 2018
3dd91b5
Renammed new attributes for more clarity and portability
TomDemulierChevret Feb 20, 2018
00fd1d7
Coerce of new attributes is only made for y axis
TomDemulierChevret Feb 20, 2018
5e0486a
Merge remote-tracking branch 'upstream/master' into rangeslider-allow…
TomDemulierChevret Feb 20, 2018
32488f1
Changed rangeslidermode values for more clarity
TomDemulierChevret Feb 20, 2018
bc2a40a
Switch to new rangeslider range opts (default missing)
TomDemulierChevret Feb 28, 2018
d3b6071
Added default attributes
TomDemulierChevret Feb 28, 2018
b496641
Remove old attributes
TomDemulierChevret Feb 28, 2018
149ef70
Add autorange computation
TomDemulierChevret Feb 28, 2018
54d8b58
Merge remote-tracking branch 'upstream/master' into rangeslider-allow…
TomDemulierChevret Feb 28, 2018
dd48914
Add missing check
TomDemulierChevret Feb 28, 2018
a8a3ee5
Add missing catch to test to retrieve the tracebacks
TomDemulierChevret Mar 2, 2018
0ae2831
Change yAxis rangeslider rangeOpts computation + fix yAxis rangeslide…
TomDemulierChevret Mar 2, 2018
8764e4d
Add missing check
TomDemulierChevret Mar 2, 2018
a17d3a8
Fix rangeslider test
TomDemulierChevret Mar 2, 2018
e85e3d0
Renamed parameter to keep name consistency across the file
TomDemulierChevret Mar 2, 2018
0dd8562
Merge remote-tracking branch 'upstream/master' into rangeslider-allow…
TomDemulierChevret Mar 2, 2018
3929be6
Changes requested by @alexcjohnson
TomDemulierChevret Mar 2, 2018
e2ad33d
Changes requested by @alexcjohnson
TomDemulierChevret Mar 2, 2018
df85f35
Changes requested by @etpinard
TomDemulierChevret Mar 5, 2018
fe83e07
Default range for 'fixed' rangemode value is now the range of the axe
TomDemulierChevret Mar 5, 2018
3b6b81a
Changes requested by @etpinard
TomDemulierChevret Mar 6, 2018
9de4e3e
Changes requested by @etpinard
TomDemulierChevret Mar 6, 2018
f2819c8
Changes requested by @etpinard
TomDemulierChevret Mar 6, 2018
df96a13
Merge branch 'master' into rangeslider-allow-zoom-on-oppaxis
TomDemulierChevret Mar 6, 2018
9c66f81
Add test for new attributes default and coerce
TomDemulierChevret Mar 7, 2018
f092c44
Add interaction test for new attributes
TomDemulierChevret Mar 7, 2018
041ce3d
Fixed autorange test precision
TomDemulierChevret Mar 7, 2018
23c8401
Fixed autorange test precision
TomDemulierChevret Mar 7, 2018
73560f6
Merge branch 'master' into rangeslider-allow-zoom-on-oppaxis
alexcjohnson Mar 7, 2018
c556f8c
rename range_attributes file -> oppaxis_attributes
etpinard Mar 7, 2018
43f15a7
add rangeslider.yaxis? to schema flagging it with _isSubplotObj
etpinard Mar 7, 2018
ccb6091
fix rangeslider.y.rangemode=auto and add a test image
alexcjohnson Mar 7, 2018
6a88b24
Merge branch 'rangeslider-allow-zoom-on-oppaxis' of github.com:TomDem…
alexcjohnson Mar 7, 2018
95b8c10
test turning on autorange via rangeslider attrs
alexcjohnson Mar 7, 2018
4f54f62
drop rangeslider style attributes to editType: plot and test
alexcjohnson Mar 7, 2018
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
12 changes: 12 additions & 0 deletions src/components/rangeslider/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,17 @@ module.exports = {
'If visible, perpendicular axes will be set to `fixedrange`'
].join(' ')
},
perpendicularaxesinitialrange: {
Copy link
Contributor

@etpinard etpinard Feb 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a little to verbose for our needs. Attribute names rarely have more than two words smashed together.

The best option that comes to my mind is xaxis.rangeslider.fixedanchor: false || true, but anchor is used already elsewhere to declare a different thing.

Looking for opinions from @alexcjohnson @cldougl and @chriddyp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I find it also too verbose but I prefered to use a clear name until we have a better proposal (since anchor is already used).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given that the range slider is always an x axis, we could use something like fixedyrange - and if we ever make a y axis range slider it can get a fixedxrange attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does makes sense, I was not quite sure rangeslider was for x-axis only.

valType: 'boolean',
dflt: true,
role: 'style',
editType: 'calc',
description: [
'Determine whether the perpendicular axes in the rangeslider',
'use (or not) their initial range when they are zoomed in the plot',
'To allow zoom one (or more) perpendicular axe(s) while the rangeslider is visible',
'you must set the attributes `fixedrange` to *true* on said axe(s).'
].join(' ')
},
editType: 'calc'
};
1 change: 1 addition & 0 deletions src/components/rangeslider/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) {

coerce('autorange', !axOut.isValidRange(containerIn.range));
coerce('range');
coerce('perpendicularaxesinitialrange');

// to map back range slider (auto) range
containerOut._input = containerIn;
Expand Down
12 changes: 6 additions & 6 deletions src/components/rangeslider/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ module.exports = function(gd) {

opts._rl = [range0, range1];

if(oppAxisOpts.fixedrange === false) {
var range0OppAxis = oppAxisOpts.r2l(oppAxisOpts._rangeBeforeZoom[0]),
range1OppAxis = oppAxisOpts.r2l(oppAxisOpts._rangeBeforeZoom[1]),
if(axisOpts.rangeslider.perpendicularaxesinitialrange && oppAxisOpts.fixedrange === false) {
var range0OppAxis = oppAxisOpts.r2l(oppAxisOpts._rangesliderInitialRange[0]),
range1OppAxis = oppAxisOpts.r2l(oppAxisOpts._rangesliderInitialRange[1]),
distOppAxis = range1OppAxis - range0OppAxis;

opts.d2pOppAxis = function(v) {
Expand Down Expand Up @@ -305,7 +305,7 @@ function setPixelRange(rangeSlider, gd, axisOpts, opts, oppAxisOpts) {
.attr('x', pixelMax)
.attr('width', opts._width - pixelMax);

if(oppAxisOpts.fixedrange === false) {
if(axisOpts.rangeslider.perpendicularaxesinitialrange && oppAxisOpts.fixedrange === false) {
var pixelMinOppAxis = opts._height - clampOppAxis(opts.d2pOppAxis(oppAxisOpts._rl[1])),
pixelMaxOppAxis = opts._height - clampOppAxis(opts.d2pOppAxis(oppAxisOpts._rl[0]));

Expand Down Expand Up @@ -428,7 +428,7 @@ function drawRangePlot(rangeSlider, gd, axisOpts, opts) {
mockFigure.layout[oppAxisName] = {
type: oppAxisOpts.type,
domain: [0, 1],
range: oppAxisOpts._rangeBeforeZoom ? oppAxisOpts._rangeBeforeZoom.slice() : oppAxisOpts.range.slice(),
range: axisOpts.rangeslider.perpendicularaxesinitialrange ? oppAxisOpts._rangesliderInitialRange.slice() : oppAxisOpts.range.slice(),
calendar: oppAxisOpts.calendar
};

Expand Down Expand Up @@ -495,7 +495,7 @@ function drawMasks(rangeSlider, gd, axisOpts, opts, oppAxisOpts) {
.call(Color.fill, constants.maskColor);

// masks used for oppAxis zoom
if(oppAxisOpts.fixedrange === false) {
if(axisOpts.rangeslider.perpendicularaxesinitialrange && oppAxisOpts.fixedrange === false) {
var maskMinOppAxis = rangeSlider.selectAll('rect.' + constants.maskMinOppAxisClassName)
.data([0]);

Expand Down
2 changes: 1 addition & 1 deletion src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ axes.saveRangeInitial = function(gd, overwrite) {
}
// store the initial range for the rangeslider if we zoom on oppaxis
if((isNew && ax.fixedrange === false) || (overwrite && hasChanged)) {
ax._rangeBeforeZoom = ax.range.slice();
ax._rangesliderInitialRange = ax.range.slice();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, one issue with this: _rangesliderInitialRange isn't part of the figure JSON... so if you zoom in on the y axis, then you decide you like the plot and you save it, or you snapshot it even, the rangeslider y axis will not have the same range in the snapshot or when you reopen the plot.

That seems to me to mean that we need a real attribute for the range of each y axis on the rangeslider, and perhaps even an attribute for whether to autorange that y axis on the range slider - it would be cool if the y axis could be told to autorange in the range slider even if you start out zoomed in on the main plot, wouldn't it?

BTW I came to this realization as I was thinking "what tests should we have for this feature", noting that a big part of this is drawing code so it should have an image test, but then realizing as it stands we can't make an image test because we have no mechanism to force _rangesliderInitialRange to be different from the y axis range in an image test, therefore we can't make the opp axis masks appear there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I didn't think about that.
I'll look into it.

}
}

Expand Down