-
-
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
Add bounds to range and autorange of cartesian, gl3d and radial axes #6547
Conversation
After chatting with @archmoj last week and playing with this, I think I understand the attributes implemented here:
Both of these are useful, but I think this is missing an important one, perhaps the first one people will think of in this vein: a specific value to use for one or the other end of autorange, for example "no matter the data, I want the bottom of the range to be 50, but I want Plotly to choose the top of the range." This would almost be a generalization of So I think we need three pairs of attributes, not just two. What if we put them all in a new container:
And two things I notice playing with the PR as it stands today:
|
I don't understand "use these values exactly for autorange" ... ? If we say "use these" then what is "auto"? |
I think a little table like this would help a little:
I assume the idea is that one could set the "in" here by e.g. panning or providing |
The original use case in #400 was to specify one end of the range exactly and have us automatically determine the other end. For that purpose (with the names I'm suggesting) let's say you specify I could also imagine saying "I want viewers always to come back to
One thing I'm noticing now is there's currently no equivalent generalization of to > Plotly.newPlot(gd,[{y:[0.01,2,3]}],{yaxis:{rangemode:'tozero'}})
> gd.layout.yaxis.range
[0, 3.2047477744807122] // entirely positive data, padding would expand past zero but tozero prevents this
> Plotly.newPlot(gd,[{y:[-0.01,2,3]}],{yaxis:{rangemode:'tozero'}})
> gd.layout.yaxis.range
[-0.2304777070063694, 3.2204777070063693] // data on both sides of zero, padding works normally
> Plotly.newPlot(gd,[{y:[-0.01,-2,-3]}],{yaxis:{rangemode:'tozero'}})
> gd.layout.yaxis.range
[-3.2047477744807122, 0] // totally negative data also won't expand past zero due to padding An alternative to creating 4 sets of attributes would be one or two sets plus another mode attribute to say how it should behave; I don't like that idea though, because with separate attributes you can specify combinations of behavior: soft and hard limits, an exact setting for one end of the range and a limit on the other end, etc. Another alternative to 4 attribute pairs would be 4 length-2 arrays, where you can use New API suggestion:With so many it's getting tough to figure out clear, concise names... maybe we put the three autorange-specific ones in a container and leave the hard limits at the top level?
So then |
I'll have some longer thoughts shortly but here are some assorted intuitions:
|
In reaction to your new API proposal, I think that |
I love the |
Here's the spreadsheet I'm imagining as the test grid for this feature btw: https://docs.google.com/spreadsheets/d/1DMyGYDSiNoemS78zKjdf_MKKGfSxm3iLQH4r64q-BNg/edit#gid=0 I have some questions around how these interact, and what happens if a min is greater than a max... |
With respect the original issue, could a simpler API just be |
I do love the simplicity of this API, and it would let us get rid of What happens though if we later change the data? We write the computed range back to So what if we create 4 new
Next question is what happens if the viewer doubleclicks, or zooms/pans and then doubleclicks - seems like mostly this should do a full autorange, ie it sets So the new API would be:
|
Good catch @LiamConnors 🙏 |
Thanks @archmoj. Looks good to me now. And I don't see any further issues. |
dflt: true, | ||
editType: 'axrange', | ||
impliedEdits: {'range[0]': undefined, 'range[1]': undefined}, | ||
description: [ | ||
'Determines whether or not the range of this axis is', | ||
'computed in relation to the input data.', | ||
'See `rangemode` for more info.', | ||
'If `range` is provided, then `autorange` is set to *false*.' | ||
'If `range` is provided, then `autorange` is set to *false*.', |
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.
this isn't necessarily true anymore 😎
Co-authored-by: Liam Connors <liam@plot.ly>
Co-authored-by: Liam Connors <liam@plot.ly>
@archmoj if I set one end of the range and ask for normal order, the behavior now is perfect AFAICT, ie either of these a doubleclick alternates between the original range and a full autorange, and if I first pan/zoom and then doubleclick, it goes to the original range first, then to a full autorange.: Plotly.newPlot(gd,[{y:[4,5,6,7]}],{yaxis:{range:[5.5,null]}})
Plotly.newPlot(gd,[{y:[4,5,6,7]}],{yaxis:{range:[null, 5.5]}}) And if I get the reversed setting precisely correct, the behavior is also correct, with axis reversed and doubleclick toggling between initial state and full autorange: Plotly.newPlot(gd,[{y:[4,5,6,7]}],{yaxis:{range:[null, 5.5], autorange:'max reversed'}})
Plotly.newPlot(gd,[{y:[4,5,6,7]}],{yaxis:{range:[5.5, null], autorange:'min reversed'}}) However, if I instead add Plotly.newPlot(gd,[{y:[4,5,6,7]}],{yaxis:{range:[null, 5.5], autorange:'reversed'}})
Plotly.newPlot(gd,[{y:[4,5,6,7]}],{yaxis:{range:[5.5, null], autorange:'reversed'}}) Also if I pick the wrong reversed option: Plotly.newPlot(gd,[{y:[4,5,6,7]}],{yaxis:{range:[null, 5.5], autorange:'max'}})
Plotly.newPlot(gd,[{y:[4,5,6,7]}],{yaxis:{range:[5.5, null], autorange:'min'}})
Plotly.newPlot(gd,[{y:[4,5,6,7]}],{yaxis:{range:[null, 5.5], autorange:'min reversed'}})
Plotly.newPlot(gd,[{y:[4,5,6,7]}],{yaxis:{range:[5.5, null], autorange:'max reversed'}}) I think would expect the |
Thanks for the review @alexcjohnson. |
Getting much closer! There's still some weird behavior if you set a partial range and As I started writing this I was hoping we could allow you to specify a single-ended range along with So I think the correct logic must be:
What do you think? Does this make sense? |
Good catch. Addressed in 30a692e. |
I think this is a desired behavior to ignore ambiguous |
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.
Fair enough. I still think there are some conditions we could consider bugs and make all of this behavior more self-consistent and simpler, but I'll make a new issue after we merge this.
💃 Nice work on a powerful addition to a very complicated part of our code!
Resolves #400.
@plotly/plotly_js