Page 1 of 1

Limiting the Axis range on zoom (non-bindable)

Posted: Tue Sep 19, 2017 6:52 am
by Claudio_G
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

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

Posted: Tue Sep 19, 2017 10:54 am
by ArctionNikolai
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,

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

Posted: Tue Sep 19, 2017 1:00 pm
by Claudio_G
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

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

Posted: Wed Sep 20, 2017 11:12 am
by ArctionNikolai
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