Skip to content

Handling zoom edge cases (#690) #708

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

Merged
merged 2 commits into from
Dec 13, 2022
Merged

Conversation

AsturaPhoenix
Copy link
Contributor

This PR includes two commits fixing the following edge cases (see #690 for details and demos):

  • unexpected isZoomedOrPanned() true after resetZoom if data changed while zoomed
  • jitter on zoom-in with fully constrained limits (like a "locked" axis)
  • zoom out against a limit vanishes to a no-op as the focal point approaches the other side of the chart

One remaining concern is that this can affect zooming out from category scales in a potentially unintuitive way; further adjustments may be possible once we decide what the desired behavior is.

Thank you; let me know if you'd like any edits!

…ounds

Scale bounds may be stale if data/bounds are updated just before getInitialScaleBounds. Among other things, this could cause isZoomedOrPanned to be false after resetZoom.

This does not address all cases where data/bounds are updated while the chart is zoomed or panned, though resetZoom now corrects this discrepancy.
Addresses at least two edge cases where minRange produced unintuitive effects:

 * When zooming in and the zoom range was close to both the min and max limits, minRange adjustment would produce jitter violating the max.
 * When zooming out against a limit, range was truncated such that a zoomout from the opposite side of the chart could no-op.

However, this may have an undesirable implication for category axis zooming since zooming out against a limit can now alternate between zooming out by 1 or 2 categories whereas before it would tend to truncate to 1.
@kurkle kurkle linked an issue Nov 24, 2022 that may be closed by this pull request
@kurkle kurkle added this to the 2.0.1 milestone Nov 24, 2022
@kurkle kurkle added the bug label Nov 24, 2022
Copy link
Member

@kurkle kurkle left a comment

Choose a reason for hiding this comment

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

LGTM

@kurkle kurkle merged commit b816d2f into chartjs:master Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zoom edge cases
3 participants