Control zoom and pan on 2D contour

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
Torben
Posts: 2
Joined: Wed Aug 09, 2017 11:13 am

Control zoom and pan on 2D contour

Post by Torben » Wed Aug 09, 2017 11:16 am

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

User avatar
ArctionNikolai
Posts: 38
Joined: Fri Feb 05, 2016 11:37 am
Location: Finland
Contact:

Re: Control zoom and pan on 2D contour

Post by ArctionNikolai » Wed Aug 09, 2017 12:14 pm

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,
Nikolai Arsenov
Software developer
Arction Ltd
Microkatu 1, 70210 Kuopio, Finland

Torben
Posts: 2
Joined: Wed Aug 09, 2017 11:13 am

Re: Control zoom and pan on 2D contour

Post by Torben » Wed Aug 09, 2017 12:56 pm

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

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: Control zoom and pan on 2D contour

Post by ArctionKestutis » Tue Aug 15, 2017 10:19 am

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.

Claudio_G
Posts: 13
Joined: Fri Sep 15, 2017 7:28 am

Re: Control zoom and pan on 2D contour

Post by Claudio_G » Tue Sep 19, 2017 7:00 am

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

User avatar
ArctionNikolai
Posts: 38
Joined: Fri Feb 05, 2016 11:37 am
Location: Finland
Contact:

Re: Control zoom and pan on 2D contour

Post by ArctionNikolai » Tue Sep 19, 2017 10:37 am

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,
Nikolai Arsenov
Software developer
Arction Ltd
Microkatu 1, 70210 Kuopio, Finland

JoseArmandoRT
Posts: 2
Joined: Wed Jul 17, 2019 3:46 am

Re: Control zoom and pan on 2D contour

Post by JoseArmandoRT » Wed Jul 17, 2019 3:50 am

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

Arction_LasseP
Posts: 141
Joined: Wed Mar 27, 2019 1:05 pm

Re: Control zoom and pan on 2D contour

Post by Arction_LasseP » Wed Jul 17, 2019 12:12 pm

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

Post Reply