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

View Limit: Improve pan/zoom behavior (4.1 vs 4.0) #1148

Closed
at2software opened this issue Jul 7, 2021 · 3 comments · Fixed by #1203
Closed

View Limit: Improve pan/zoom behavior (4.1 vs 4.0) #1148

at2software opened this issue Jul 7, 2021 · 3 comments · Fixed by #1203

Comments

@at2software
Copy link

at2software commented Jul 7, 2021

The AxisBounds() method from v4.0.48 seems to have been replaced by SetViewLimits() in v4.1.x. However, upon dragging, the new method now automatically scales / zooms. If exaggerated, this might result in an invalid axis in below example.

Can the old AxisBounds() behaviour be mimicked in v4.1.x?

We have this code in v4.0.48

double[] data = new double[35];
Random rand = new Random(0);
for (int i = 1; i < data.Length; i++)
	data[i] = data[i - 1] + rand.NextDouble() - .5;

plot1.plt.PlotSignal(data);
plot1.plt.AxisBounds(minY: 0);
plot1.Render();

And adapted the last 3 lines to v4.1.16 like this:

plot1.Plot.AddSignal(data);
plot1.Plot.SetViewLimits(yMin: 0);
plot1.Render();

In v4.0.48, the plot can be dragged upwards, as long as there is allowed space available, but stops at y=0.
SetViewLimits from v4.1.16 behaves similarly, but when the y=0 limit is hit, the graph gets scaled vertically (and, if exaggerated, the y-axis seems to be broken or flipped / inverted).

Here's a screencap of the behaviours:

2021-07-07_14_05_14_axpt.mp4
@at2software

This comment has been minimized.

@swharden swharden changed the title Difference between AxisBounds and SetViewLimit in 4.1.x View Limit: Improve pan/zoom behavior (4.1 vs 4.0) Aug 4, 2021
@swharden swharden removed the Question label Aug 10, 2021
swharden added a commit that referenced this issue Aug 10, 2021
discovered while working on #1148
swharden added a commit that referenced this issue Aug 10, 2021
swharden added a commit that referenced this issue Aug 10, 2021
demonstrates issue #1148
swharden added a commit that referenced this issue Aug 10, 2021
Previously applying axis view limits could result in unexpected zooming in (#1148). Now applying axis boundaries pans axis limits to avoid zooming when limiting.
@swharden
Copy link
Member

Thanks for reporting this @at2software! Your description and videos were excellent

I was able to recreate the issue with a (failing) test, then correct it. This will be fixed in the next NuGet release 👍🚀

double[] values = DataGen.RandomWalk(new Random(0), 100);
formsPlot1.Plot.AddSignal(values);
formsPlot1.Plot.SetViewLimits(yMin: 0);
before after
before after

@at2software
Copy link
Author

Great, thanks a lot!

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 a pull request may close this issue.

2 participants