Nevron Forum

How to limit data zooming?

https://www.nevron.com/Forum/Topic8194.aspx

By Vladimir Bershadsky - Monday, September 30, 2013

Hello!

I am using Nevron Chart (v2012Vol1 Enterprise) to draw some measure-over-time 2D line graphs. Data Zooming Tool is used to provide user with basic zoom capabilities. Now I want to prevent user from going too deep with zooming. For example, to limit x-axis zoom to 1 second and y-axis (values) zoom to 0.0001, and if user selects lesser range, prevent zoom from happening. I tried this code to set minimal values of NRangeSelection object:

            chartControl.Charts[0].RangeSelections.Clear();
            NRangeSelection rangeSelection = new NRangeSelection();
            rangeSelection.HorizontalValueSnapper = new NAxisRulerClampSnapper();
            rangeSelection.VerticalValueSnapper = new NAxisRulerClampSnapper();
            double oaSecond = DateTime.Today.AddSeconds(1).ToOADate() - DateTime.Today.ToOADate();
            rangeSelection.MinHorizontalPageSize = oaSecond;
            rangeSelection.MinVerticalPageSize = 0.001;
            rangeSelection.ZoomOutResetsAxis = false;
            chartControl.Charts[0].RangeSelections.Add(rangeSelection);

but this didn't help. It seems like even when user selects lesser range (for example, 0.00001 on vertical axis), Chart control still perfoms zoom-in for vertical axis.

Please help. Thank you in advance,
Vladimir

By Nevron Support - Tuesday, October 1, 2013

Hi Vladimir,

We just tested the control with the following code:

   NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

   DateTime today = DateTime.Today;
   double oaSecond = today.AddSeconds(1).ToOADate() - today.ToOADate();

   NRangeSelection rangeSelection = new NRangeSelection();
   rangeSelection.HorizontalValueSnapper = new NAxisRulerClampSnapper();
   rangeSelection.VerticalValueSnapper = new NAxisRulerClampSnapper();
   
   rangeSelection.MinHorizontalPageSize = oaSecond;
   rangeSelection.MinVerticalPageSize = 0.001;

   rangeSelection.ZoomOutResetsAxis = false;
   chart.RangeSelections.Add(rangeSelection);

   chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NDateTimeScaleConfigurator();
   chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;
   chart.Axis(StandardAxis.PrimaryY).ScrollBar.Visible = true;

   NPointSeries point = new NPointSeries();
   point.UseXValues = true;
   point.DataLabelStyle.Visible = false;

   for (int i = 0; i < 100; i++)
   {
    point.Values.Add(i / 1000.0);
    point.XValues.Add(today.ToOADate());

    today = today.AddSeconds(1);
   }

   chart.Series.Add(point);

   nChartControl1.Controller.Tools.Add(new NSelectorTool());
   nChartControl1.Controller.Tools.Add(new NAxisScrollTool());
   nChartControl1.Controller.Tools.Add(new NDataZoomTool());

and it was working properly. Can you try to download the latest version from our website and confirm the problem appears there?

By Vladimir Bershadsky - Tuesday, October 1, 2013

After downloading newer build from site and reinstalling control, I've examined my data zooming issue thoroughly once more. The problem continues to appear.

Please see attached image LimitingZoom.jpg for illustration. Although I set rangeSelection.MinVerticalPageSize to 0.001, you can clearly see that Y-axis resolution is lower (i.e. user succeeded to zoom-in deeper than 0.001).

My idea about zoom limiting, that if user tries to select zooming range with lesser length than allowed, zoom is cancelled and nothing happens. Possibly this was not your intention and control does not supposed to work in this way. If so, please instruct or hint me to how can I achieve desired results.

Thank you for your help.

Vladimir

By Nevron Support - Tuesday, October 1, 2013

Hi Vladimir,

We think the control is working properly - the begin value of the y axis is:

1.5940

assuming you've set 0.001 as max zoom length the minimum value for the axis range end can be 1.5950 and the value is bigger than that so it works correctly...

By Vladimir Bershadsky - Wednesday, October 2, 2013

Hi,

Thank you! It is clear to me now. I checked this issue once more and now I can see that control really does not perform zoom, only moves page view to reflect selection.

Best regards,

Vladimir