Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
my chart is slow down after sometime of application starting.

What I have tried:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace chart
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        double a,b,c = 0;
        private void Form1_Load(object sender, EventArgs e)
        {

        }
        
        private void timer1_Tick(object sender, EventArgs e)
        {
            a = a + 1;
            b = b + 3;
            timervaluee.Text=a.ToString()+ "," + b.ToString()+ "," + c.ToString();
            chart1.Series[0].Points.AddXY(a, b);
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
                timer1.Start();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            chart1.Series[0].Points.Clear();           
        }

        private void button3_Click(object sender, EventArgs e)
        {
            timer1.Stop();
        }
    }
}
Posted
Updated 20-Mar-19 5:09am
v2
Comments
Mohibur Rashid 20-Mar-19 5:25am    
Have you considered using external library?

1 solution

Well yes. You are adding points to the chart at regular intervals, giving it more work to do. When the amount of data to plot takes more time to process than is available between two Ticks, everything will start to slow down.

Start by thinking about the volume of data you are plotting, how you are plotting it, if there are any data reductions you can introduce, and perhaps either look at a commercial library or writing your own specifically for that data type and volume.
 
Share this answer
 
Comments
Mohamed Fahad 20-Mar-19 6:30am    
i really dont know how to do it
OriginalGriff 20-Mar-19 6:36am    
Which bit?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900