-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Rangeslider allow zoom on oppaxis #2364
Changes from all commits
519e1a7
044e633
f335258
707f432
6a7f652
fc4f082
92c6550
b30167c
91caff1
3dd91b5
00fd1d7
5e0486a
32488f1
bc2a40a
d3b6071
b496641
149ef70
54d8b58
dd48914
a8a3ee5
0ae2831
8764e4d
a17d3a8
e85e3d0
0dd8562
3929be6
e2ad33d
df85f35
fe83e07
3b6b81a
9de4e3e
f2819c8
df96a13
9c66f81
f092c44
041ce3d
23c8401
73560f6
c556f8c
43f15a7
ccb6091
6a88b24
95b8c10
4f54f62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright 2012-2018, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'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'], | ||
dflt: 'match', | ||
role: 'style', | ||
editType: 'calc', | ||
description: [ | ||
'Determines whether or not the range of this axis in', | ||
'the rangeslider use the same value than in the main plot', | ||
'when zooming in/out.', | ||
'If *auto*, the autorange will be used.', | ||
'If *fixed*, the `range` is used.', | ||
'If *match*, the current range of the corresponding y-axis on the main subplot is used.' | ||
].join(' ') | ||
}, | ||
range: { | ||
valType: 'info_array', | ||
role: 'style', | ||
items: [ | ||
{valType: 'any', editType: 'plot'}, | ||
{valType: 'any', editType: 'plot'} | ||
], | ||
editType: 'plot', | ||
description: [ | ||
'Sets the range of this axis for the rangeslider.' | ||
].join(' ') | ||
}, | ||
editType: 'calc' | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,12 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce, | |
|
||
var autoRange = coerce('autorange', !containerOut.isValidRange(containerIn.range)); | ||
|
||
// both x and y axes may need autorange done just for the range slider's purposes | ||
// the logic is complicated to figure this out later, particularly for y axes since | ||
// the settings can be spread out in the x axes... so instead we'll collect them | ||
// during supplyDefaults | ||
containerOut._rangesliderAutorange = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very clear comment. Thanks! |
||
|
||
if(autoRange) coerce('rangemode'); | ||
|
||
coerce('range'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"data": [ | ||
{"y": [4, 7e7, 5e5, 6e8, 3e2], "type": "bar"}, | ||
{"y": [1, 4, 2, 6, 3], "xaxis": "x2", "yaxis": "y2"} | ||
], | ||
"layout": { | ||
"xaxis": { | ||
"domain": [0, 0.42], | ||
"range": [1, 3], | ||
"rangeslider": { | ||
"yaxis": {"rangemode": "auto"} | ||
}, | ||
"title": "Rangeslider Y rangemode auto" | ||
}, | ||
"xaxis2": { | ||
"anchor": "y2", | ||
"domain": [0.58, 1], | ||
"range": [1.5, 3.5], | ||
"rangeslider": { | ||
"range": [-2, 4], | ||
"yaxis2": {"rangemode": "fixed", "range": [0, 10]} | ||
}, | ||
"title": "Rangeslider Y2 rangemode fixed" | ||
}, | ||
"yaxis": {"type": "log", "range": [2, 6], "title": "Y explicit range"}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice mock! |
||
"yaxis2": {"anchor": "x2", "title": "Y2 autoranged"}, | ||
"width": 700, | ||
"height": 500 | ||
} | ||
} |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 that is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexcjohnson we should be able to change these to
editType: 'plot'
, correct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh hmm... actually I don't think we can, it's like
ax.autorange
which is stillcalc
, because this affects_rangesliderAutorange
which determines whether we even bother calculatingax._min/_max
during thecalc
step.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I tried switching them to
'plot'
, but that didn't break any test 😕