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
10 changes: 9 additions & 1 deletion src/components/rangeslider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@

'use strict';

var Lib = require('../../lib');
var attrs = require('./attributes');
var oppAxisAttrs = require('./oppaxis_attributes');

module.exports = {
moduleType: 'component',
name: 'rangeslider',

schema: {
subplots: {
xaxis: {rangeslider: require('./attributes')}
xaxis: {
rangeslider: Lib.extendFlat({}, attrs, {
yaxis: oppAxisAttrs
})
}
}
},

Expand Down
5 changes: 5 additions & 0 deletions src/components/rangeslider/oppaxis_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
'use strict';

module.exports = {
// not really a 'subplot' attribute container,
// but this is the flag we use to denote attributes that
// support yaxis, yaxis2, yaxis3, ... counters
_isSubplotObj: true,

rangemode: {
valType: 'enumerated',
values: ['auto', 'fixed', 'match'],
Expand Down
12 changes: 9 additions & 3 deletions test/jasmine/tests/plotschema_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,15 @@ describe('plot schema', function() {
});

it('all subplot objects should contain _isSubplotObj', function() {
var IS_SUBPLOT_OBJ = '_isSubplotObj',
astrs = ['xaxis', 'yaxis', 'scene', 'geo', 'ternary', 'mapbox', 'polar'],
cnt = 0;
var IS_SUBPLOT_OBJ = '_isSubplotObj';
var cnt = 0;

var astrs = [
'xaxis', 'yaxis', 'scene', 'geo', 'ternary', 'mapbox', 'polar',
// not really a 'subplot' object but supports yaxis, yaxis2, yaxis3,
// ... counters, so list it here
'xaxis.rangeslider.yaxis'
];

// check if the subplot objects have '_isSubplotObj'
astrs.forEach(function(astr) {
Expand Down
21 changes: 21 additions & 0 deletions test/jasmine/tests/validate_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,4 +505,25 @@ describe('Plotly.validate', function() {
'In layout, key grid.subplots[2][0] is set to an invalid value (5)'
);
});

it('should detect opposite axis range slider attributes', function() {
var out = Plotly.validate([
{y: [1, 2]},
{y: [1, 2], yaxis: 'y2'},
{y: [1, 2], yaxis: 'y3'}
], {
xaxis: {
rangeslider: {
yaxis: { rangemode: 'auto' },
yaxis2: { rangemode: 'fixed' },
yaxis3: { range: [0, 1] }
}
},
yaxis: {},
yaxis2: {},
yaxis3: {}
});

expect(out).toBeUndefined();
Copy link
Contributor

Choose a reason for hiding this comment

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

As promised in https://github.com/plotly/plotly.js/pull/2364/files#r171957082

Please note, the _isSubplotObj flag in the range slider opposite axis attributes is very important. Without it, this test would spit out:

image

that is Plotly.validate would think that rangeslider.yaxis2 and rangeslider.yaxis3 aren't part of the schema.

Copy link
Contributor

@etpinard etpinard Mar 7, 2018

Choose a reason for hiding this comment

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

Note that this appears to work in plotly.py aswell.

Copying the new plot-schema.json over there gives:

image

i.e. does not fail like:

image

cc @cldougl @Kully

});
});