Nevron Forum

Which event for Zooming

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

By Frank Thiesing - Tuesday, November 8, 2011

Hello,

i use a Nevron-Chart, their i use zoom. Now i need the range from my X-Axis after zoom. I tried it with HorizontalAxisRangeChanged-Event. But this event is fired the hole time i am select the part in my chart.


void rangeSelection_HorizontalAxisRangeChanged(object sender, EventArgs e)
{
NRangeSelection nrs = (NRangeSelection)sender;
Console.WriteLine(nrs.HorizontalAxisRange.Begin + " " + nrs.HorizontalAxisRange.End);
Console.WriteLine(cartesianChart.Axis(StandardAxis.PrimaryX).PageRange.Begin + " | " + cartesianChart.Axis(StandardAxis.PrimaryX).PageRange.End);
}
After zoom i will call a method, but it would be hard to call this method more than once.
Can you help please.

best regards
By Nevron Support - Tuesday, November 8, 2011

Hi Frank,

You can intercept the data zoom end drag event and get the axis ruler range from there - for example:

  private void Form1_Load(object sender, EventArgs e)
  {
   NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

   NBarSeries bar = new NBarSeries();

   bar.Values.Add(10);
   bar.Values.Add(20);
   bar.Values.Add(30);

   chart.Series.Add(bar);

   chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator();

   NRangeSelection rs = new NRangeSelection();
   chart.RangeSelections.Add(rs);

   nChartControl1.Controller.Tools.Add(new NSelectorTool());
   NDataZoomTool dzt = new NDataZoomTool();
   dzt.EndDrag += new EventHandler(dzt_EndDrag);
   nChartControl1.Controller.Tools.Add(dzt);
  }

  void dzt_EndDrag(object sender, EventArgs e)
  {
   NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

   nChartControl1.Document.Calculate();
   nChartControl1.Document.RecalcLayout(nChartControl1.View.Context);

   NRange1DD xAxisRange = chart.Axis(StandardAxis.PrimaryX).Scale.RulerRange;
   textBox1.Text = "X: " + xAxisRange.Begin.ToString() + " Y: " + xAxisRange.End.ToString();
  }

Hope this helps - let us know if you meet any problems.

By Frank Thiesing - Wednesday, November 9, 2011

Hello,

thanks for your help, it works.
Now i get the begin and the end of my range selection. I configure my xaxis in a datetime format.
Is there a way to convert the double value i get from selection to a DateTime-Value?

best regards
By Nevron Support - Wednesday, November 9, 2011

Hi Frank,

Yes - you should use FromOADate:

DateTime dt = DateTime.FromOADate(someDoubleValue);