Profile Picture

Zoom and multi Yaxis

Posted By Hans Henrik Friis Pedersen... 9 Years Ago
Author
Message
Hans Henrik Friis Pedersen...
Question Posted 9 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 8 Years Ago
Posts: 28, Visits: 136
Hi,

I'm adding a NDataZoomTool and a NSelectorTool and a NDataPanTool() to a NCartesianChart followed by adding a RangeSelections


m_Chart.RangeSelections.Add(new NRangeSelection());


NDataZoomTool m_DataZoomTool = new NDataZoomTool();
ChartControl.Controller.Tools.Add(m_DataZoomTool);
ChartControl.Controller.Tools.Add(new NSelectorTool());
NDataPanTool dpt = new NDataPanTool();
ChartControl.Controller.Tools.Add(dpt);


I would like to perform a Zoom of a muliYaxis plot, see Image 1. However, when I try to Zoom in a on part of the graph only the left Y-axis is scaled according the zoom - the right Y-axis is not scaled (is ot affected by the zoom) - see attached Image 2 and Image 3.


Attachments
Image_1.png (483 views, 206.00 KB)
Image_2.png (495 views, 227.00 KB)
Image_3.png (492 views, 297.00 KB)
joern kunze
Posted 9 Years Ago
View Quick Profile
Junior Member

Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)

Group: Forum Members
Last Active: 3 Months Ago
Posts: 86, Visits: 221
Hello Hans,

 I have had a similar problem - and couldnt find sort of build in function to do so. Hence I implemented it manually:

Implement the following within the OnDataZoom_EndDrag - Event:
         NRange1DD contentRange = oChart.Axis(StandardAxis.PrimaryX).ViewRange;
          NRange1DD viewRange = oChart.Axis(StandardAxis.PrimaryX).Scale.RulerRange;
          double beginFactor = contentRange.GetValueFactor(viewRange.Begin);
          double endFactor = contentRange.GetValueFactor(viewRange.End);

          bool bolXZoomActive = (beginFactor == 0.0 && endFactor == 1.0) ? false : true;

          // compute factors Y Zoom
          contentRange = oChart.Axis(StandardAxis.PrimaryY).ViewRange;
          viewRange = oChart.Axis(StandardAxis.PrimaryY).Scale.RulerRange;
          beginFactor = contentRange.GetValueFactor(viewRange.Begin);
          endFactor = contentRange.GetValueFactor(viewRange.End);

          bool bolYZoomActive = (beginFactor == 0.0 && endFactor == 1.0) ? false : true;


          if (_PlotData.MultipleYAxis && true) {    //NewFeature: MultipleYAxis 2014_09           
           // then for all other y axes make sure their view range factor equals to begin/end factor
           if (bolYZoomActive) {
            // disable Scrollbar for all Y-Axis except primary YAxis
            foreach (NAxis axis in oChart.Axes) {
              if (axis.AxisId != (int)StandardAxis.PrimaryY && axis.AxisOrientation == AxisOrientation.Vertical) {
               axis.PagingView.Enabled = true;

               // compute the new range based on factor
               NRange1DD axisContentRange = axis.ViewRange;
               double rangeLength = axisContentRange.End - axisContentRange.Begin;

               double begin = axisContentRange.Begin + beginFactor * rangeLength;
               double end = axisContentRange.Begin + endFactor * rangeLength;

               axis.PagingView.ZoomIn(new NRange1DD(begin, end), 0.0001);
              }
            }

           }
           else {
            // full view no zoom
            foreach (NAxis axis in oChart.Axes) {
              if (axis.AxisId != (int)StandardAxis.PrimaryY && axis.AxisOrientation == AxisOrientation.Vertical) {
               axis.PagingView.Enabled = false;
              }
            }
           }

          }

          bool bolRecalcLayout = _PlotData.MultipleYAxis;

Maybe afterwards you have to do the following as well:
_NevronChart.document.Calculate();   //ruler values must be calculated first
_NevronChart.document.RecalcLayout(_NevronChart.View.Context);
_NevronChart.Refresh();

Best regards,
Joern

Nevron Support
Posted 9 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Yesterday @ 1:54 AM
Posts: 3,054, Visits: 4,009

Hi All,
You can also check out the following example - All Examples \ Interactivity \ Tools \ Multiple Axes Zooming and Scrolling - it shows how to simultaneously zoom in / out two vertical axes.



Best Regards,
Nevron Support Team



joern kunze
Posted 9 Years Ago
View Quick Profile
Junior Member

Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)Junior Member (13 reputation)

Group: Forum Members
Last Active: 3 Months Ago
Posts: 86, Visits: 221
Thanks for the example, Nevron Support Team. 

When I use the OnDataZoom_EndDrag, basically everything works as expected. But I have slightly a problem when the red dot of the PagingView is pressed after multiple zooming has been done (e.g. X-Axis has a total range from10 to 90; then first zoom in 20 to 80 and then zoom even further in from 50 to 60 - and now click red dot of the PagingViewBar near the XAxis) :
in this case, the OnDataZoom_EndDrag-event is fired, but the following doesnt work anymore:

Implementation in OnDataZoom_EndDrag-Event:
_NevronChart.document.Calculate();
_NevronChart.document.RecalcLayout(_NevronChart.View.Context);
...
oChart.Axis(StandardAxis.PrimaryX).CalculateAxis(_NevronChart.View.Context);
NRange1DD contentRange = oChart.Axis(StandardAxis.PrimaryX).ViewRange;
contentRange = oChart.Axis(StandardAxis.PrimaryX).ContentRange;
NRange1DD viewRange = oChart.Axis(StandardAxis.PrimaryX).Scale.RulerRange;

=> now oChart.Axis(StandardAxis.PrimaryX).ViewRange and oChart.Axis(StandardAxis.PrimaryX).Scale.RulerRange are the same
and return for the example above  10 to 90 instead 20 to 80.
The real shown view afterwards however, is from 20 to 80.

Is there a way to force oChart.Axis(StandardAxis.PrimaryX).Scale.RulerRange to return the correct values (20 to 80) within the OnDataZoom_EndDrag-Event?

When I look to the Nevron example (All Examples \ Interactivity \ Tools \ Multiple Axes Zooming and Scrolling), the prefered event for doing so should be Scale_RulerRangeChanged. I understand this. But since the OnDataZoom_EndDrag is fired when the red dot is clicked, it should also be working correctly (or it should not be fired at all in this case).

Thanks for the help,
Best regards,
Joern




Nevron Support
Posted 9 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Yesterday @ 1:54 AM
Posts: 3,054, Visits: 4,009
Hi Joern,

Most likely you have the NDataZoomTool added before the NAxisScrollTool in the tools collection.
You need to make sure that the NAxisScrollTool is added first in the collection and you should not get the end drag event fired at all. Let us know if the problem persists.


Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic