Limiting the Axis range on zoom (non-bindable)

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Arction_LasseP

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

Limiting the Axis range on zoom (non-bindable)

Post by Claudio_G » Tue Sep 19, 2017 6:52 am

What is the best way to limit the axis range when the user is zooming on the axis?

On the ViewXY there is a BeforeZooming event, but it doesn't get raised when the user does a wheel zooming on the axis itself. On the axis there is a RangeChanged event but it does not allow to cancel the zoom and there is no way to retrieve the old zoom values as it only exposes the NewMax and NewMin (which are the same as axis.Minimum/Maximum).

Code: Select all

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));
        }
results in new values being the same as e.Axis values

axisX_RangeChanged - NewMin: 32311.2172471072 - NewMax: 32371.2172471072 - CurrentMin: 32311.2172471072 - CurrentMax: 32371.2172471072

As my data samples come in at about 25ms, I dont need to zoom in more than 200ms and I would like to limit the zooming to that.

Do I need to recalculate and reassign Minimum and Maximum from within RangeChanged?

Thanks

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

Re: Limiting the Axis range on zoom (non-bindable)

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

Hello,

Yes, I apologize for the misleading in this post https://forum.arction.com/viewtopic.php?f=16&t=1264. When the event handler returns a callback the NewMin and NewMax values had been applied before. These arguments are mainly for a fast access.
Do I need to recalculate and reassign Minimum and Maximum from within RangeChanged?
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. Yes, here you can check everything that you need and reassign the ranges properly.
Additionally, you can take a look on ViewXY.BeforeZooming event. Here you will get an Old ranges information together with the Newest. It will be easier for you to decide should the specific axis be rescaled or not.

Best regards,
Nikolai Arsenov
Software developer
Arction Ltd
Microkatu 1, 70210 Kuopio, Finland

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

Re: Limiting the Axis range on zoom (non-bindable)

Post by Claudio_G » Tue Sep 19, 2017 1:00 pm

Thank you, I got the expected behavior.

BTW, inside the RangeChangedBaseEventArgs there is a funny foobar() method. I wonder what it does :lol:

You can find it also in the Help (.chm) file

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

Re: Limiting the Axis range on zoom (non-bindable)

Post by ArctionNikolai » Wed Sep 20, 2017 11:12 am

BTW, inside the RangeChangedBaseEventArgs there is a funny foobar() method. I wonder what it does :lol:
Yes, during writing the answer for you yesterday, I was surprised to find it. :D
Nikolai Arsenov
Software developer
Arction Ltd
Microkatu 1, 70210 Kuopio, Finland