Page 1 of 1

Control zoom and pan on 2D contour

Posted: Wed Aug 09, 2017 11:16 am
by Torben
Hi,

We use a 2D contour plot and like that the user can zoom on the plot

But how do I prevent the user from zooming out?
He is allowed to zoom in and then back to start, but he cannot be allowed to zoom out so the chart background become visible

Also I cannot see how to disable pan 100%

Regards Torben

Re: Control zoom and pan on 2D contour

Posted: Wed Aug 09, 2017 12:14 pm
by ArctionNikolai
Hello Torben,

All the Properties related to zooming and panning can be found in _chart.ViewXY.ZoomPanOptions, each property is explaind in Chapter 6.21 LightningChart Users Manual.

For disabling the Pan over the ViewXY, add this line to your code, because Panning is for the Right-mouse button:

Code: Select all

_chart.ViewXY.ZoomPanOptions.RightMouseButtonAction = MouseButtonAction.None;
Furthermore, please remember to disable pan for each XY axis you use, because you can pan by dragging the axis. For example:

Code: Select all

axisX.PanningEnabled = false;
axisY.PanningEnabled = false;
Handling the situation where your client cannot zoom out, preventing chart background to be visible, you have to control it in a code.
- Subscribe to the event either 1 _chart.ViewXY.BeforeZooming+= or 2 axis.RangeChanged events ( 1 for each XY axis).
- For BeforeZooming, you get access to ranges via e.XRanges / e.YRanges, which contains an info about OldMin, OldMax, NewMin, NewMax;
For RangeChanged almost the same thing, but it contains only e.NewMin and e.NewMax, the old values you can get from e.Axis.Maximum, e.Axis.Minimal.
- Check the validation of a new range, because you know what size your Contour map has.

Both methods produce the same. However, RangeChanged event will be attached to all axes, which will occur N times (where n = xAxesCount + yAxesCount) more than only one BeforZooming event.

Best regards,

Re: Control zoom and pan on 2D contour

Posted: Wed Aug 09, 2017 12:56 pm
by Torben
Hi,

Thanks I got i running now.

PS my documentation does not have a chapter 6.21. Chapter 6 only goes to 6.19.
The version in the documentation says 8.1.1.
If you have a better one that gives a good explanation off the pan and zoom options please post a link

Regards Torben

Re: Control zoom and pan on 2D contour

Posted: Tue Aug 15, 2017 10:19 am
by ArctionKestutis
In the latest User's Manual Zooming, panning and rotating chapter is numbered as 6.17 (it may vary depending on precise revision)

All the best.

Re: Control zoom and pan on 2D contour

Posted: Tue Sep 19, 2017 7:00 am
by Claudio_G
I am trying to use this approach to limit my zoom on ViewXY but the RangeChanged doesnt have the old zoom data.

this is a debug print I have made and you can see how the new values are the same as the e.Axis.Minimum and Maximum. Did I not understand what you wrote in your previous post?

private void axisX_RangeChanged(object sender, RangeChangedEventArgs e)
{
Debug.WriteLine(String.Format("axisX_RangeChanged - NewMin: {0} - NewMax: {1} - CurrentMin: {2} - CurrentMax: {3}", e.NewMin, e.NewMax, e.Axis.Minimum, e.Axis.Maximum));
}

axisX_RangeChanged - NewMin: 30753.4980306653 - NewMax: 30993.4980306653 - CurrentMin: 30753.4980306653 - CurrentMax: 30993.4980306653

Re: Control zoom and pan on 2D contour

Posted: Tue Sep 19, 2017 10:37 am
by ArctionNikolai
Claudio_G wrote:I am trying to use this approach to limit my zoom on ViewXY but the RangeChanged doesnt have the old zoom data.

This is a debug print I have made and you can see how the new values are the same as the e.Axis.Minimum and Maximum. Did I not understand what you wrote in your previous post?

private void axisX_RangeChanged(object sender, RangeChangedEventArgs e)
{
Debug.WriteLine(String.Format("axisX_RangeChanged - NewMin: {0} - NewMax: {1} - CurrentMin: {2} - CurrentMax: {3}", e.NewMin, e.NewMax, e.Axis.Minimum, e.Axis.Maximum));
}

axisX_RangeChanged - NewMin: 30753.4980306653 - NewMax: 30993.4980306653 - CurrentMin: 30753.4980306653 - CurrentMax: 30993.4980306653
Hello,

Yes, I apologize for the misleading. When the event handler returns a callback the NewMin and NewMax values had been applied before. These arguments are mainly for a fast access.
The solution for you can be to create few local members to keep old Min and Max values and assign them when it is needed in RangeChanged event callback.

Best regards,

Re: Control zoom and pan on 2D contour

Posted: Wed Jul 17, 2019 3:50 am
by JoseArmandoRT
Hello,

I can only avoid panning with mouse by changing this parameter axis.MouseInteraction = false;

Am i doing something wrong with axis.panningenable = false?

Regards

Re: Control zoom and pan on 2D contour

Posted: Wed Jul 17, 2019 12:12 pm
by Arction_LasseP
Hello Jose,

PanningEnabled -property prevents panning the chart to the direction of the axis when dragging it with mouse (hold mouse right button and drag by default). It does not affect dragging the axis itself.

Here are the properties which control various zooming and panning interactions. They can be used with both X- and Y-axes.

axis.MouseInteraction = false;
- Disables all mouse interaction with the axis.

axis.PanningEnabled = false;
- Prevents panning the chart when dragging it with mouse. Does not prevent dragging the axis.

axis.MouseScrolling = false;
- Prevents dragging the axis. The chart itself can still be panned.

axis.MouseScaling = false;
- Prevents scaling the axis via dragging the ScaleNibs

axis.ZoomingEnabled = false;
- Zooming does not affect this axis

Of these, disabling MouseScrolling could be the most useful for you.

Hope this helps.
Best regards,
Lasse