Skip to content

Handle case of nonnegative or tozero rangemodes for inside ticklabels - #5331

Merged
archmoj merged 6 commits into
masterfrom
nonnegative-inside-ticklabels
Dec 9, 2020
Merged

Handle case of nonnegative or tozero rangemodes for inside ticklabels#5331
archmoj merged 6 commits into
masterfrom
nonnegative-inside-ticklabels

Conversation

@archmoj

@archmoj archmoj commented Dec 9, 2020

Copy link
Copy Markdown
Contributor

@plotly/plotly_js

@archmoj archmoj added bug something broken status: reviewable labels Dec 9, 2020
@archmoj
archmoj requested a review from alexcjohnson December 9, 2020 16:18
Comment thread src/plots/cartesian/autorange.js Outdated
if(ax.rangemode !== 'nonnegative') {
A = padInsideLabelsOnAnchorAxis(ax, max);

if(anchorAxis.rangemode !== 'nonnegative') {

Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

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.

Comment thread src/plots/cartesian/autorange.js Outdated
if(!isLinked(fullLayout, ax._id)) {
A = padInsideLabelsOnAnchorAxis(ax, max);
B = padInsideLabelsOnThisAxis(ax, max);
if(ax.rangemode !== 'nonnegative') {

Copy link
Copy Markdown
Collaborator

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.

Comment thread src/plots/cartesian/autorange.js Outdated
if(
anchorAxis.rangemode !== 'tozero' &&
anchorAxis.rangemode !== 'nonnegative'
) {

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Contributor Author

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.

@archmoj archmoj changed the title Handle case of nonnegative rangemode for inside ticklabels Handle case of nonnegative or tozero rangemodes for inside ticklabels Dec 9, 2020

@alexcjohnson alexcjohnson left a comment

Copy link
Copy Markdown
Collaborator

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! 💃

@archmoj
archmoj merged commit 9291457 into master Dec 9, 2020
@archmoj
archmoj deleted the nonnegative-inside-ticklabels branch December 9, 2020 21:18
@archmoj archmoj added the regression this used to work label Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug something broken regression this used to work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants