Wrong Ranges after Zoom-Reset

Found a possible bug in LightningChart? Report it here.

Moderator: Queue Moderators

Post Reply
frank
Posts: 51
Joined: Tue Mar 25, 2014 9:04 am

Wrong Ranges after Zoom-Reset

Post by frank » Tue Jul 01, 2014 12:25 pm

Hi,

I'm using the mouse-gesture (left mouse button and moving cursor left) to reset the zoom and zoom out.
After zooming out, I can't zoom in again. In BeforeZooming-Event, the xRanges[0].NewMin and xRanges[0].NewMax are equal to the Min and Max of the chart, not the zooming arera. If I trigger the zoom a second time, the Ranges are correct and the zoom is performed.

ArctionTero
Posts: 42
Joined: Thu Mar 28, 2013 9:20 am

Re: Wrong Ranges after Zoom-Reset

Post by ArctionTero » Tue Jul 01, 2014 1:08 pm

Hi,

We can't reproduce the issue, so could you provide more information how you exactly initialize ViewXY.ZoomPanOptions?

And what do you do in the BeforeZooming event?

Are you using WinForms or WPF chart?

Thank you.
LightningChart Support Team, TK

frank
Posts: 51
Joined: Tue Mar 25, 2014 9:04 am

Re: Wrong Ranges after Zoom-Reset

Post by frank » Tue Jul 01, 2014 1:47 pm

Hi Tero,

I'm using WPF chart. I'm initializing ViewXY.ZoomPanOptions as follows:

Code: Select all

_chart.ViewXY.ZoomPanOptions.PanDirection = PanDirection.Horizontal;
_chart.ViewXY.ZoomPanOptions.RectangleZoomDirectionLayered = RectangleZoomDirectionLayered.Horizontal;
_chart.ViewXY.ZoomPanOptions.RightToLeftZoomAction = RightToLeftZoomAction.RevertAxisRanges;
_chart.ViewXY.ZoomPanOptions.MouseWheelZooming = MouseWheelZooming.Off;
_chart.ViewXY.ZoomPanOptions.AxisMouseWheelAction = AxisMouseWheelAction.None;
_chart.ViewXY.ZoomPanOptions.ZoomRectLine = new LineStyle { Color = _linienschriebSettings.AxesColor };
I have multiple charts in one window, and they should all be synchronized when panning and zooming, so if the chart in one window is zoomed in, I have to bind the values so the other windows are informed.

Code: Select all

        void BeforeZooming(List<RangeChangeInfo> xRanges, List<RangeChangeInfo> yRanges, bool byWheel, ref bool cancel)
        {
            IsZooming = !(Math.Round(xRanges[0].NewMin, 1) == Math.Round(CurrentXMin, 1) && Math.Round(xRanges[0].NewMax, 1) == Math.Round(CurrentXMax, 1));
            if (IsZooming)
            {
                if (Math.Round(xRanges[0].NewMin + ZoomLimit, 1) >= Math.Round(xRanges[0].NewMax, 1) ||
                   (Math.Round(xRanges[0].NewMin, 1) < CurrentXMin) ||
                    (Math.Round(xRanges[0].NewMax, 1) > CurrentXMax))
                {
                    cancel = true;
                }
            }

            if (!cancel)
            {
                ZoomXMin = xRanges[0].NewMin;
                ZoomXMax = xRanges[0].NewMax;
            }
        }
Best regards,
Frank

ArctionTero
Posts: 42
Joined: Thu Mar 28, 2013 9:20 am

Re: Wrong Ranges after Zoom-Reset

Post by ArctionTero » Wed Jul 02, 2014 6:19 am

Hi Frank,

I tried your code with minor changes in BeforeZooming handler method and guesses of CurrentXMin, CurrentXMax, ZoomXMin and ZoomXMax.
The BeforeZooming event seems to have valid ranges.
I have two charts in the WPF test application and their initialization is identical and both uses same event handler code.

The changes/guesses:
- CurrentXMin and CurrentXMax are private doubles, initialized to x-axis min and max at start.
- x-axis RangeRevertMin: 0, RangeRevertMax: 20.
- no action inside if (IsZooming) block, so it always zoomed. What do you use as axis range and ZoomLimit values?
- IsZooming is local variable, no property/member.
- ZoomXMin and ZoomXMax are properties, which set both charts single x-axis to related values, e.g. min:

Code: Select all

        double ZoomXMin
        {
            get { return CurrentXMin; }
            set
            {
                m_chart.ViewXY.XAxes[0].Minimum = value;
                m_chart2.ViewXY.XAxes[0].Minimum = value;
                CurrentXMin = value;
            }
        }
ZoomXMax/CurrentXMax is similar.

So it may still be a bug in chart, but could you doublecheck your ZoomXMin/-Max, CurrentXMin/-Max and IsZooming properties, how/if they change axis min/max or RangeRevert values?

Also do you have any handler for axis RangeChanged?
LightningChart Support Team, TK

frank
Posts: 51
Joined: Tue Mar 25, 2014 9:04 am

Re: Wrong Ranges after Zoom-Reset

Post by frank » Wed Jul 02, 2014 7:14 am

Hi Tero,

CurrentXMin, CurrentXMax, RangeRevertXMin, RangeRevertXMax, ZoomXMin, ZoomXMax and IsZooming are all DependencyPropertys. The mainwindow holds a collection of my ViewModels, each managing one Chart.

In if(isZooming) the zooming is canceled by setting cancel=true, ZoomLimit is set to 2:

Code: Select all

if (IsZooming)
   {
    if (...)
      {
        cancel = true;
       }
     }
In the screenshots you can see the two debug screens after first and second try to zoom, while 244 is the real maximum of the chart.
I have a RangeChanged event, but this also isn't fired in the first try of zooming in.
Attachments
FirstZoomAfterZoomOut.png
FirstZoomAfterZoomOut.png (20.38 KiB) Viewed 29073 times
SecondZoomAfterZoomOut.png
SecondZoomAfterZoomOut.png (21.41 KiB) Viewed 29073 times

ArctionTero
Posts: 42
Joined: Thu Mar 28, 2013 9:20 am

Re: Wrong Ranges after Zoom-Reset

Post by ArctionTero » Wed Jul 02, 2014 9:16 am

Hi Frank,

This is a tricky one to reproduce.. So questions follow:
- which version of the chart you have (should have asked this first..)?
- are there more than one y-axis?
- and how you set up ViewXY.AxisLayout?
I have following kind of log for RangeChanged and BeforeZooming, could you produce one?

Code: Select all

2.7.2014 11:58:30 BeforeZooming() 0..20 -> 3.61290322580645..18.7741935483871
2.7.2014 11:58:30 RangeChanged(3.61290322580645..20)
2.7.2014 11:58:30 RangeChanged(3.61290322580645..20)
2.7.2014 11:58:30 RangeChanged(3.61290322580645..18.7741935483871)
2.7.2014 11:58:30 RangeChanged(3.61290322580645..18.7741935483871)
2.7.2014 11:58:42 BeforeZooming() 3.61290322580645..18.7741935483871 -> 5.91155046826223..16.6711758584807
2.7.2014 11:58:42 RangeChanged(5.91155046826223..18.7741935483871)
2.7.2014 11:58:42 RangeChanged(5.91155046826223..18.7741935483871)
2.7.2014 11:58:42 RangeChanged(5.91155046826223..16.6711758584807)
2.7.2014 11:58:42 RangeChanged(5.91155046826223..16.6711758584807)
2.7.2014 11:58:50 BeforeZooming() 5.91155046826223..16.6711758584807 -> 7.33459769729113..14.3457084354335
2.7.2014 11:58:50 RangeChanged(7.33459769729113..16.6711758584807)
2.7.2014 11:58:50 RangeChanged(7.33459769729113..16.6711758584807)
2.7.2014 11:58:50 RangeChanged(7.33459769729113..14.3457084354335)
2.7.2014 11:58:50 RangeChanged(7.33459769729113..14.3457084354335)
Code for BeforeZooming:

Code: Select all

            foreach (RangeChangeInfo rci in xRanges)
            {
                System.Diagnostics.Debug.Print("{0} BeforeZooming() {1}..{2} -> {3}..{4}", DateTime.Now.ToString(), rci.OldMin, rci.OldMax, rci.NewMin, rci.NewMax);
            }
RangeChanged:

Code: Select all

            System.Diagnostics.Debug.Print("{0} RangeChanged({1}..{2})", DateTime.Now.ToString(), newMin, newMax);
LightningChart Support Team, TK

frank
Posts: 51
Joined: Tue Mar 25, 2014 9:04 am

Re: Wrong Ranges after Zoom-Reset

Post by frank » Wed Jul 02, 2014 9:41 am

Hi Tero,

I'm using latest Version 6.0.6.4001.
There can be mor than one y-axis, but in this example there is only one y-axis with multiple lines on it (as you can see in the screenshot).
Here is the log:
  • 02.07.2014 11:39:00 BeforeZooming() 0..111.39 -> 9.50185590778098..26.3869106628242
    02.07.2014 11:39:00 RangeChanged(9.50185590778098..26.3869106628242)
    02.07.2014 11:39:00 RangeChanged(9.50185590778098..26.3869106628242)
    02.07.2014 11:39:00 RangeChanged(9.5..26.39)
    02.07.2014 11:39:02 BeforeZooming() 9.5..26.39 -> 12.2160288184438..21.6685878962536
    02.07.2014 11:39:02 RangeChanged(12.2160288184438..21.6685878962536)
    02.07.2014 11:39:02 RangeChanged(12.2160288184438..21.6685878962536)
    02.07.2014 11:39:02 RangeChanged(12.22..21.67)
    02.07.2014 11:39:06 BeforeZooming() 12.22..21.67 -> 12.6775216138329..20.5697694524496
    02.07.2014 11:39:06 RangeChanged(12.6775216138329..20.5697694524496)
    02.07.2014 11:39:06 RangeChanged(12.6775216138329..20.5697694524496)
    02.07.2014 11:39:06 RangeChanged(12.68..20.57)
    02.07.2014 11:39:08 BeforeZooming() 12.68..20.57 -> 0..111.3879
    02.07.2014 11:39:08 RangeChanged(0..111.39)
    02.07.2014 11:39:10 BeforeZooming() 0..111.39 -> 0..111.3879
    02.07.2014 11:39:15 BeforeZooming() 0..111.39 -> 5.007734870317..29.4043919308357
    02.07.2014 11:39:15 RangeChanged(5.007734870317..29.4043919308357)
    02.07.2014 11:39:15 RangeChanged(5.007734870317..29.4043919308357)
    02.07.2014 11:39:15 RangeChanged(5.01..29.4)
    02.07.2014 11:39:19 BeforeZooming() 5.01..29.4 -> 10.0848069164265..22.9897175792507
    02.07.2014 11:39:19 RangeChanged(10.0848069164265..22.9897175792507)
    02.07.2014 11:39:19 RangeChanged(10.0848069164265..22.9897175792507)
    02.07.2014 11:39:19 RangeChanged(10.08..22.99)
    02.07.2014 11:39:20 BeforeZooming() 10.08..22.99 -> 0..111.3879
    02.07.2014 11:39:20 RangeChanged(0..111.39)
    02.07.2014 11:39:21 BeforeZooming() 0..111.39 -> 0..111.3879
    02.07.2014 11:39:23 BeforeZooming() 0..111.39 -> 3.14588472622478..31.0094351585014
    02.07.2014 11:39:23 RangeChanged(3.14588472622478..31.0094351585014)
    02.07.2014 11:39:24 RangeChanged(3.14588472622478..31.0094351585014)
    02.07.2014 11:39:24 RangeChanged(3.15..31.01)
Best regards,
Frank
Attachments
Chart.png
Chart.png (23.75 KiB) Viewed 29069 times

ArctionTero
Posts: 42
Joined: Thu Mar 28, 2013 9:20 am

Re: Wrong Ranges after Zoom-Reset

Post by ArctionTero » Wed Jul 02, 2014 10:24 am

Hi Frank,

Seems you round axis range somewhere, but that may not matter.
Do you have three charts and you update axis values only when max is set on model, not when min?
Could you tell us how you initialize ViewXY.AxisLayout?

Thanks.
LightningChart Support Team, TK

frank
Posts: 51
Joined: Tue Mar 25, 2014 9:04 am

Re: Wrong Ranges after Zoom-Reset

Post by frank » Wed Jul 02, 2014 12:07 pm

Hi,

if there is only one y-axis (as in this example)

Code: Select all

ViewXY.AxisLayout.AutoAdjustMargins = false;
ViewXY.AxisLayout.YAxisTitleAutoPlacement = false;
ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Layered;
else

Code: Select all

ViewXY.AxisLayout.AutoAdjustMargins = false;
ViewXY.AxisLayout.YAxisTitleAutoPlacement = false;
ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Stacked;
ViewXY.AxisLayout.AutoShrinkYAxesGap = true;
ViewXY.AxisLayout.StackedYAxesGap = 10;
Yes, I update only, wehn max is set to not trigger the rangechanged twice. There where two charts opened.

frank
Posts: 51
Joined: Tue Mar 25, 2014 9:04 am

Re: Wrong Ranges after Zoom-Reset

Post by frank » Tue Jul 08, 2014 8:41 am

Are there any news to this?

ArctionTero
Posts: 42
Joined: Thu Mar 28, 2013 9:20 am

Re: Wrong Ranges after Zoom-Reset

Post by ArctionTero » Mon Jul 21, 2014 7:45 am

Hi Frank,

Sorry for late answer. We have made some fixes to zooming since 6.0.6.

Does this still occur with 6.0.9?
LightningChart Support Team, TK

frank
Posts: 51
Joined: Tue Mar 25, 2014 9:04 am

Re: Wrong Ranges after Zoom-Reset

Post by frank » Mon Jul 21, 2014 2:57 pm

Hi Tero,

in a quick test the problem seems to be solved. But now there is drawn a white rectangle when performing RightToLeftZoomAction. Can I switch that off somehow?

Best regards,
Frank
Attachments
RightToLeftAction.png
RightToLeftAction.png (26.64 KiB) Viewed 28725 times

ArctionTero
Posts: 42
Joined: Thu Mar 28, 2013 9:20 am

Re: Wrong Ranges after Zoom-Reset

Post by ArctionTero » Wed Jul 23, 2014 5:52 am

Hi Frank,

Glad to hear it works.

You can "hide" zoom-out rectangle by setting:

Code: Select all

chart.ViewXY.ZoomPanOptions.ZoomOutRectLine.Color = Color.Transparent;
LightningChart Support Team, TK

frank
Posts: 51
Joined: Tue Mar 25, 2014 9:04 am

Re: Wrong Ranges after Zoom-Reset

Post by frank » Wed Jul 23, 2014 9:18 am

Thanks!

Post Reply