Skip to content
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

Fixup rangebreaks l2p and p2l functions #4699

Merged
merged 14 commits into from
Mar 29, 2020
Merged

Fixup rangebreaks l2p and p2l functions #4699

merged 14 commits into from
Mar 29, 2020

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Mar 28, 2020

Following of #4614,
this PR fixes l2p & p2l functions

@plotly/plotly_js

@archmoj archmoj added this to the v1.53.0 milestone Mar 29, 2020
@archmoj archmoj changed the title Improve hover when rangebreaks are present Fixup rangebreaks l2p and p2l functions Mar 29, 2020
@alexcjohnson
Copy link
Collaborator

What's going on with autorange in axes_breaks-night_autorange-reversed.png ? Both the orange and red subplots prior to this PR have tight clipping on one side, and after this PR the tight clipping is on the other side. Neither side should have tight clipping, they should both get 5% padding. Also what's with the label 23:22 that's in the same place both before and after this PR, despite the axis range changing?

Screen Shot 2020-03-29 at 2 13 28 PM

else {
// when falls into break, pick 'closest' offset
q = pos > (min + max) / 2 ? nextI : i;
q = signAx * pos > signAx * (min + max) / 2 ? nextI : i;
Copy link
Collaborator

Choose a reason for hiding this comment

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

l2p is a hot path, so it's worth optimizing a good deal - even if it means some duplicated code, though I'm not sure if that would help here, and even if the code needs more comments and is less self-documenting. For example:

  • signAx * pos could be done once up front, and var min = signAx * brk.min etc would simplify these conditionals a bit
  • first and last look unnecessary
  • Flip _m2 for y axes after using it to calculate _B, so we don't need the (isY ? -1 : 1) * down below.
  • Move var isY = axLetter === 'y' to the outer scope, where axLetter was defined.

p2l I think is generally not as hot, though maybe for some traces it's used in hover? Not sure. (Note that c2p uses l2p and p2c uses p2l)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good calls. Addressed in the commits below.

@archmoj
Copy link
Contributor Author

archmoj commented Mar 29, 2020

What's going on with autorange in axes_breaks-night_autorange-reversed.png ? Both the orange and red subplots prior to this PR have tight clipping on one side, and after this PR the tight clipping is on the other side. Neither side should have tight clipping, they should both get 5% padding. Also what's with the label 23:22 that's in the same place both before and after this PR, despite the axis range changing?

Screen Shot 2020-03-29 at 2 13 28 PM

Fixed by 749430d.

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

Excellent work! 💃

@archmoj archmoj merged commit ebab12b into master Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rangebreaks mapping on reversed ranges rangebreaks hovermode=closest offset
2 participants