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

Maintain limits on ViewBox scaling #2054

Merged

Conversation

NilsNemitz
Copy link
Contributor

As described in #2001 , the absolute limits of values represented by double-precision floating-point values can be reached very quickly by zooming out in logarithmic mode: The AxisItems start calculating with out of range values when the logarithmic representation exceeds +/-308, which can be reached with two or three spins of the mouse wheel.

In normal mode, it takes a little longer to get there, but it is similarly possible to create failures by simply zooming out too far.

This PR initialized the range limits in normal mode to be +/-1E307 (close to the absolute range limits, with a slight extra margin to avoid earlier out-of-range values in internal calculations. It also applies additional limits of about +/308 to the allowed ViewBox scaling range when in logarithmic mode, corresponding to log10 of the range limit.

Downsides:

  • ViewBox now has to be made aware when logarithmic mapping is activated for one of the axes, which was not the case previously.
  • The limiting code now executes on every update, although I do not expect the limited number of additional calculations to present a noticeable limit to performance.

I am hoping for comments.

This closes #2001.

@j9ac9k
Copy link
Member

j9ac9k commented Nov 6, 2021

Upon further check for adding a test, I noticed the axes change, but the rendering doesn't; short of some kind of assertImageMatch or something like that; this might be a tougher case to test for; and given this PR fixed an issue, I'm going to merge this as is.

Thanks for the PR @NilsNemitz and thanks for generating the example of the issue in #2001 @pijyoi

@j9ac9k j9ac9k merged commit 81bcc48 into pyqtgraph:master Nov 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Axis can be zoomed out until program becomes unresponsive
2 participants