Skip to content

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

@at2software

Description

@at2software

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions