Page 1 of 1

XRanges empty on zooming out

Posted: Mon Apr 13, 2015 6:57 am
by frank
Up to a new release shortly I colud use the following code, having RightToLeft Zoomout enabled:

Code: Select all

 private void BeforeZooming(List<RangeChangeInfo> xRanges, List<RangeChangeInfo> yRanges, bool byWheel, ref bool cancel)
        {
            ...
            IsZooming = !(Equals(xRanges[0].NewMin, RangeXMin) && Equals(xRanges[0].NewMax, RangeXMaximum));
            ...
        }
But now it crashes when the chart is zoomed out and the user performs another RightToLeft-Event because xRanges is empty. I'm catching this case already, but this behaviour was new to me.

Re: XRanges empty on zooming out

Posted: Tue Apr 14, 2015 12:48 pm
by ArctionPasi
Hi Frank,

I'm not able to reproduce the problem.

Code: Select all

using Arction.WPF.LightningChartUltimate; 

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {

        LightningChartUltimate m_chart; 
        public MainWindow()
        {
            InitializeComponent();

            m_chart = new LightningChartUltimate();
            gridMain.Children.Add(m_chart);

            m_chart.BeginUpdate();

            m_chart.ViewXY.ZoomPanOptions.RightToLeftZoomAction = RightToLeftZoomAction.ZoomOut;
            m_chart.ViewXY.BeforeZooming += ViewXY_BeforeZooming;


            m_chart.EndUpdate(); 
        }

        void ViewXY_BeforeZooming(List<RangeChangeInfo> xRanges, List<RangeChangeInfo> yRanges, bool byWheel, ref bool cancel)
        {
            if (xRanges == null || xRanges.Count == 0 || yRanges == null || yRanges.Count == 0)
            {
                System.Diagnostics.Debug.WriteLine("Something missing");
            }

            bool bZooming = !(Equals(xRanges[0].NewMin, m_chart.ViewXY.XAxes[0].Minimum) && Equals(xRanges[0].NewMax, m_chart.ViewXY.XAxes[0].Maximum));
            if (bZooming)
                System.Diagnostics.Debug.WriteLine("Zooming");
            else
                System.Diagnostics.Debug.WriteLine("NOT Zooming");
        
        }
    }
}
Output window shows "Zooming" message only. If params are null or empty, it should say "Something missing" instead.

Can you modify the project until the error appears? :|

Re: XRanges empty on zooming out

Posted: Wed Apr 15, 2015 6:22 am
by frank
Sure. Please have a look at the attached sample.

Best regards,
Frank

Re: XRanges empty on zooming out

Posted: Wed Apr 15, 2015 8:17 am
by ArctionPasi
Thanks.

Only the Y axes that are set to zoom, are enlisted in List<RangeChangeInfo> yRanges.
In the code you sent, Y axes zooming is disabled:
_chart.ViewXY.ZoomPanOptions.RectangleZoomDirection = RectangleZoomDirection.Horizontal

X axes are zoomed only.

If _chart.ViewXY.ZoomPanOptions.RectangleZoomDirection = RectangleZoomDirection.Vertical, xRanges list is empty.

If _chart.ViewXY.ZoomPanOptions.RectangleZoomDirection = RectangleZoomDirection.Both, xRanges and yRanges list are both filled. Provided that each axis.ZoomingEnabled = true.

We have lately modified zooming features a lot and some changes are inevitable. I'm sorry this has caused confusion for you.

Re: XRanges empty on zooming out

Posted: Wed Apr 15, 2015 8:36 am
by frank
Hi Pasi,
Only the Y axes that are set to zoom, are enlisted in List<RangeChangeInfo> yRanges.
As you can see in my first post, I'm talking about the xRanges

Code: Select all

xRanges[0].NewMin
doesn't work any more.

Regards,
Frank

Re: XRanges empty on zooming out

Posted: Wed Apr 15, 2015 9:23 am
by ArctionPasi
If new range is same than the old range, it seems to RangeChangeInfo item with a null axis object and NewMin and NewMax = 0 in the xRanges list.

You have set
_chart.ViewXY.ZoomPanOptions.RightToLeftZoomAction = RightToLeftZoomAction.RevertAxisRanges

And by applying right-to-left action twice in row will cause the problem to appear, because the revert values are not changed in your code.

For now, please just check if the RangeChangeInfo's Axis is 'null' and if it is, don't do anything with it.

I'll issue a fix process so that not-changed axes don't add empty items in the lists.