Page 1 of 1

Realtime curve with windows mobile 5

Posted: Tue Aug 25, 2009 1:01 pm
by 13052852
Hi,
I use TeeChart .net 3 with VS2005 on a Pocket PC with windows mobile 5. I try to display a curve every 500 ms using FasLine type but the dynamic performance are so Bad (1.5 s or 1s in the best case) ! Is there a way to Have a "realtime" display?

thanks

Re: Realtime curve with windows mobile 5

Posted: Tue Aug 25, 2009 2:08 pm
by narcis
Hi hchiker,

You could do something as in the example below. You could implement the button code in timer's event and modify it to fit your needs.

Code: Select all

  public Form1()
  {
   InitializeComponent();
   InitializeChart();
  }

  int nrOfSamples = 1000000;
  private Steema.TeeChart.Styles.FastLine fastline1;
  private System.Diagnostics.Stopwatch stopWatch;

  private void InitializeChart()
  {
   stopWatch = new System.Diagnostics.Stopwatch();

   tChart1.Aspect.View3D = false;
   tChart1.Aspect.SmoothingMode = 
System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
   tChart1.Legend.Visible = false;
   tChart1.Axes.Bottom.SetMinMax(0, nrOfSamples);

   fastline1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);

   //pre-assign ChartPens
   Pen rPen = new Pen(Color.Red);
   Steema.TeeChart.Drawing.ChartPen redPen = new 
Steema.TeeChart.Drawing.ChartPen(tChart1.Chart, rPen);
   fastline1.LinePen = redPen;
   fastline1.DrawAllPoints = false;
   fastline1.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.None;

   tChart1.AfterDraw += new 
Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
  }

  void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D 
g)
  {
   //calculate elapsed time
   //stopWatch.Stop();
   TimeSpan elapsedTime = stopWatch.Elapsed;
   string total = elapsedTime.TotalSeconds.ToString();
   label1.Text = "Elapsed time: " + total + " s";
  }

  private void button1_Click(object sender, EventArgs e)
  {
   button1.Enabled = false;

   stopWatch.Reset();
   stopWatch.Start();

   tChart1.AutoRepaint = false;

   double[] x1 = new double[nrOfSamples];
   for (int i = 0; i < x1.Length; i++)
   {
    x1[i] = i;
   }

   double[] random1 = new double[nrOfSamples];

   FillArray(random1);
   //fastline1.Add(x1, random1);

   fastline1.XValues.Value = x1;
   fastline1.XValues.Count = nrOfSamples;

   fastline1.YValues.Value = random1;
   fastline1.YValues.Count = nrOfSamples;

   tChart1.AutoRepaint = true;
   tChart1.Refresh();
   Application.DoEvents();

   stopWatch.Stop();

   button1.Enabled = true;
  }

  private static void FillArray(double[] myArray)
  {
   Random y = new Random();
   for (int i = 0; i < myArray.Length; i++)
   {
    myArray[i] = y.Next();
   }
  }
Hope this helps!

Re: Realtime curve with windows mobile 5

Posted: Tue Aug 25, 2009 2:32 pm
by 13052852
Hi,
thanks for your answer.
I have a similar code for update the chart and it works fine on PC but the pocket version is too slow. Can I add some improvment for the TeeChart.Pocket version ?
Thanks

Re: Realtime curve with windows mobile 5

Posted: Wed Aug 26, 2009 8:15 am
by narcis
Hi hchiker,

Can you please send us a simple example project we can run "as-is" so that we can try to optimize it?

Thanks in advance.