Page 1 of 1

Real time update problems

Posted: Wed Jul 01, 2009 9:29 am
by 14045263
Hello,

I'm having major problems using the FastLine series to display real time data. The chart keeps on freezing. Data seems to be adding to the chart OK, but every so often the display freezes. Forcing a refresh by resizing the window causes the data to display correctly, only for the same thing to happen a few minutes later.

I'm using up to 8 FastLine series. Data is being added to each series at the rate of 2 points every 2 seconds. The number of data points is from 600 - 3600 data points per series. I've read the old FAQ on real time data.

The program seems to work OK on very fast new PCs but fails on 2 or 3 years old PCs, so I presume that TChart is struggling with this number of series and data points -- although 2 points every 2 seconds seems quite slow.

I'm using TChart 3.5.3425.20244. This is a cut down version of the code I'm using. Unfortunately, I can't provide you with a sample program as this program is talking to hardware.

Have you any ideas?

Thanks

Mike

Code: Select all

for (int i = 0; i < 8; i++)
{
    Steema.TeeChart.Styles.FastLine line = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
    line.Tag = i;
    line.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.None;
}

Code: Select all

for (int i = 0; i < 8; i++)
{
    double x1 = DataArray[this.index - 2, 0];
    double x2 = DataArray[this.index - 1, 0];
    
    double y1 = DataArray[this.index - 2, i + 1] * 1000.0;
    double y2 = DataArray[this.index - 1, i + 1] * 1000.0;


    tChart1.Series[i].Add(x1, y1);
    tChart1.Series[i].Add(x2, y2);

    tChart1.Series[i].RefreshSeries();
}

Re: Real time update problems

Posted: Wed Jul 01, 2009 11:58 am
by narcis
Hi Mike,

I'm not able to reproduce the issue here using code below with latest TeeChart for .NET v3 release in a machine with an AMD Athlon 64 3000+ CPU and 1 GB of RAM.


Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        
        private System.Windows.Forms.Timer timer1;
       
        private void InitializeChart()
        {
            timer1 = new Timer();
            timer1.Enabled = true;
            timer1.Interval = 2;

            for (int i = 0; i < 8; i++)
            {
                Steema.TeeChart.Styles.FastLine line = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
                line.Tag = i;
                line.XValues.Order = Steema.TeeChart.Styles.ValueListOrder.None;
            }

            AddPoints();

            timer1.Tick += new EventHandler(timer1_Tick);
        }

        void timer1_Tick(object sender, EventArgs e)
        {
            AddPoints();
        }

        private void AddPoints()
        {
            tChart1.AutoRepaint = false;
            Random rnd = new Random();

            for (int i = 0; i < 8; i++)
            {
                double x1 = rnd.Next(100) - 2;
                double x2 = rnd.Next(100) - 1;
                double y1 = rnd.Next(1000) - 2;
                double y2 = rnd.Next(1000) - 1;
                tChart1.Series[i].Add(x1, y1);
                tChart1.Series[i].Add(x2, y2);
                //tChart1.Series[i].RefreshSeries();
            }

            tChart1.Header.Text = tChart1[0].Count.ToString();
            tChart1.AutoRepaint = true;
            tChart1.Refresh();
        }
Thanks in advance.

Re: Real time update problems

Posted: Wed Jul 01, 2009 11:59 am
by 14045263
Some extra information, in case it helps:

The Steema.TeeChart.TChart.AfterDraw event is not fired when the chart freezes.

Thanks

Re: Real time update problems

Posted: Wed Jul 01, 2009 12:07 pm
by narcis
Hi noaksey,

Thanks for the information but we don't see the chart freezing here. Using the code I posted and drawing over 3600 points for each series in mentioned computer we see the chart header still adding points to the series. Can you please check how this goes for you?

Thanks in advance.

Re: Real time update problems

Posted: Wed Jul 01, 2009 3:23 pm
by 14045263
Hello,

I've modified my code to match yours. I've added the AutoRepaint false/true and the tChart.Refresh() line after adding all the points. I've removed the RefreshSeries line.

This seems to have improved things. I've been testing it all afternoon and no freezes yet. I'll continue testing over the next couple of days and let you know how I get on.

Thanks for your help