Hi Mark,
You can use the EndDrag event and add only the data thats contained in the calculated axis range. The following code example shows how to achieve this:
double[] m_xValues = new double[1000];
double[] m_yValues = new double[1000];
private void Form1_Load(object sender, EventArgs e)
{
NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
NRangeSelection rs = new NRangeSelection();
chart.RangeSelections.Add(rs);
NPointSeries point = new NPointSeries();
Random rand = new Random();
point.DataLabelStyle.Visible = false;
point.UseXValues = true;
// generate some dummy data
for (int i = 0; i < 1000; i++)
{
m_xValues[i] = rand.Next(1000);
m_yValues[i] = rand.Next(1000);
}
// feed data to point series
point.XValues.AddRange(m_xValues);
point.Values.AddRange(m_yValues);
chart.Series.Add(point);
chart.Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(new NRange1DD(0, 1000), true, true);
chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 1000), true, true);
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 yRange = chart.Axis(StandardAxis.PrimaryY).Scale.RulerRange;
NRange1DD xRange = chart.Axis(StandardAxis.PrimaryX).Scale.RulerRange;
AddDataInRange(xRange, yRange);
}
private void AddDataInRange(NRange1DD xRange, NRange1DD yRange)
{
NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
NPointSeries point = (NPointSeries)chart.Series[0];
point.XValues.Clear();
point.Values.Clear();
for (int i = 0; i < 1000; i++)
{
if (xRange.Contains(m_xValues[i]) && yRange.Contains(m_yValues[i]))
{
point.XValues.Add(m_xValues[i]);
point.Values.Add(m_yValues[i]);
}
}
}
Hope this helps - let us know if you have any questions or meet any problems.
Best Regards,
Nevron Support Team