-
-
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
Handle case of nonnegative or tozero rangemodes for inside ticklabels #5331
Conversation
src/plots/cartesian/autorange.js
Outdated
if(ax.rangemode !== 'nonnegative') { | ||
A = padInsideLabelsOnAnchorAxis(ax, max); | ||
|
||
if(anchorAxis.rangemode !== 'nonnegative') { |
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.
why would rangemode
of anchorAxis
be relevant?
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.
Good question. Fixed in f31d97c.
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.
Wait. I had to revert the commit.
src/plots/cartesian/autorange.js
Outdated
@@ -226,8 +226,13 @@ function makePadFn(fullLayout, ax, max) { | |||
var A = 0; | |||
var B = 0; | |||
if(!isLinked(fullLayout, ax._id)) { | |||
A = padInsideLabelsOnAnchorAxis(ax, max); | |||
B = padInsideLabelsOnThisAxis(ax, max); | |||
if(ax.rangemode !== 'nonnegative') { |
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.
I don't think this is really the condition we want - we're not trying to completely prevent extra padding for labels when rangemode
is 'nonnegative'
, we just want to prevent the range from going past zero. ie we never want this to prevent the high end of the range from expanding to make room for the labels, nor do we want to prevent the low end from expanding unless it's going to go past zero - so for example if you have for example scatter points from 1 to 10 and there are inside labels on the low end, so that without labels the range would be something like [0.4, 10.6]
, the labels should expand the range down to zero but not beyond.
src/plots/cartesian/autorange.js
Outdated
if( | ||
anchorAxis.rangemode !== 'tozero' && | ||
anchorAxis.rangemode !== 'nonnegative' | ||
) { |
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.
I don't think we want any of these rangemode
conditions, now that you have nopad
in the fallback conditions above. Basically in your new ticklabelposition-5
mock, only the blue one should have labels overlapping bars. Maybe you want to flip either the red or green labels to the bottom, in which case those would overlap the bars too, but otherwise just the blue should hit this condition.
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.
I removed one of the checks in 0b254e7 but kept the other one.
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.
The test images look good now, but I don't understand what the remaining check is doing - can you explain?
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.
I drop the second check as you suggested.
After further investigation, it looks now that we could possibly drop padInsideLabelsOnThisAxis
function which used to tweaks the range for giving the start/end labels more chance to appear on the graph. But I'd rather trying that in a separate PR.
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.
Fantastic. Very nice test images! 💃
@plotly/plotly_js