Huge number of data display issue

TeeChart for ActiveX, COM and ASP
Post Reply
David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Huge number of data display issue

Post by David » Fri Nov 13, 2009 5:06 am

I have to display 6 series of data and each series may contain up to 4 million sampled data. To display the series, I can think of 2 ways. One is to plot all at once after all data are collected, and the other is to display N data each time CVICALLBACK EveryNCallback is triggered and append consecutive sets of N data. Would anyone please suggest which way is better? Any other way to plot such huge number of data? Any issues I need to take care like how to refresh?

And could anyone please comment which version, ActiveX or NET, of teechart is suitable in terms of refreshing speed to display large number of data?

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Re: Huge number of data display issue

Post by David » Mon Nov 16, 2009 8:59 am

Anyone? Please advice.

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Huge number of data display issue

Post by Yeray » Mon Nov 16, 2009 9:07 am

Hi David,

First, please take a look at the Real-time Charting article here where some important performance hints are described.

I'd recommend you to make two simple test applications to simulate the final application (one with the .NET eval and one with the ActiveX eval) because the final performance will depend on the specific application needs. Here you have a performance test in both versions we made for another customer:

.NET performance test

Code: Select all

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

        int nrOfSamples = 10000;
        private Steema.TeeChart.Styles.FastLine fastline1;
        private Steema.TeeChart.Styles.FastLine fastline2;
        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;

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

            //pre-assign ChartPens
            Pen rPen = new Pen(Color.Red);
            Pen bPen = new Pen(Color.Blue);
            Steema.TeeChart.Drawing.ChartPen redPen = new Steema.TeeChart.Drawing.ChartPen(tChart1.Chart, rPen);
            Steema.TeeChart.Drawing.ChartPen bluePen = new Steema.TeeChart.Drawing.ChartPen(tChart1.Chart, bPen);
            fastline1.LinePen = redPen;
            fastline2.LinePen = bluePen;

            fastline1.FillSampleValues(nrOfSamples);
            fastline2.FillSampleValues(nrOfSamples / 2);

            //tChart1.Axes.Left.SetMinMax(-5.0, 5.0);

            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[] x2 = new double[nrOfSamples / 2];
            for (int i = 0; i < x2.Length; i++)
            {
                x2[i] = i;
            }
            double[] random1 = new double[nrOfSamples];
            double[] random2 = new double[nrOfSamples / 2];

            for (int i = 0; i < 100; i++)
            {
                FillArray(random1);
                FillArray(random2);
                fastline1.Add(x1, random1);
                fastline2.Add(x2, random2);
                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();
            }
        }
ActiveX performance test

Code: Select all

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

        int nrOfSamples = 10000;
        private System.Diagnostics.Stopwatch stopWatch;

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

            axTChart1.Aspect.View3D = false;
            //tChart1.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;

            axTChart1.AddSeries(TeeChart.ESeriesClass.scFastLine);
            axTChart1.AddSeries(TeeChart.ESeriesClass.scFastLine);

            axTChart1.Series(0).FillSampleValues(nrOfSamples);
            axTChart1.Series(1).FillSampleValues(nrOfSamples / 2);

            //axTChart1.Axis.Left.SetMinMax(-5.0, 5.0);

            axTChart1.OnAfterDraw += new EventHandler(axTChart1_OnAfterDraw);
        }

        void axTChart1_OnAfterDraw(object sender, EventArgs e)
        {
            //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();

            //axTChart1.AutoRepaint = false;

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

            for (int i = 0; i < 100; i++)
            {
                FillArray(random1);
                FillArray(random2);
                axTChart1.Series(0).AddArray(x1.Length, random1, x1);
                axTChart1.Series(1).AddArray(x2.Length, random2, x2);
                //tChart1.AutoRepaint = true;
                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();
            }
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Re: Huge number of data display issue

Post by David » Mon Nov 16, 2009 9:55 am

Hi, Yeray,

Thanks for your post, and you have answered the second part of my question. Would you please also advice on the first part, as how to more effectively plot huge number of data?

David

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Huge number of data display issue

Post by Yeray » Mon Nov 16, 2009 10:43 am

Hi David,

The slowest process with a lot of data is when this data is going to be drawn. That means that your application will be faster if you draw as few data as possible and refresh the chart as few times as possible.
So I'd recommend you to add all the data at the same time (with autorepaint=false) and paint your chart then.

Please, take a look at the article I mentioned above.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply