Profile Picture

Zooming virtualization

Posted By Mark Edwards 13 Years Ago
Author
Message
Mark Edwards
Posted 13 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 1, Visits: 1
I'm using the built in NDataZoomTool to zoom, but it is an incredible amount of data and hence, slow. I'd like to use my database to filter out records based on a given zoom level. How do I either create new lines or update the lines' values based on the result of a zoom operation?

Nevron Support
Posted 13 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: Last Week
Posts: 3,054, Visits: 4,009

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





Similar Topics


Reading This Topic