I am plotting real time graph using RollingPointPairList of Zedgraph. I am receiving 100 point per second and trying to plot 100 point per second. But zedgraph shows lag and is able to plot only maximum 20 point per second. I am using following code for plotting
RollingPointPairList samp = new RollingPointPairList(105);
private void Form1_Load(object sender, EventArgs e)
{
CreateGraph(zg1);
SetSize();
}
int x1 = 0;
private void TimerEventProcessor(int[] diff)
{
zg1.GraphPane.XAxis.Scale.MaxAuto = true;
x1 += 1;
samp.Add(diff[0], x1);
if (samp.Count >= 100)
{
zg1.AxisChange();
zg1.Invalidate();
zg1.Refresh();
Thread.Sleep(50);
}
}
private void Form1_Resize(object sender, EventArgs e)
{
SetSize();
}
private void SetSize()
{
zg1.Location = new Point(10, 10);
zg1.Size = new Size(this.ClientRectangle.Width - 10, this.ClientRectangle.Height - 10);
}
private void CreateGraph(ZedGraphControl zgc)
{
GraphPane myPane = zgc.GraphPane;
myPane.Title.Text = "Test";
myPane.XAxis.Title.Text = "X Value";
myPane.YAxis.Title.Text = "Y Axis";
LineItem myCurve;
myCurve= myPane.AddCurve("Curve 1", samp, Color.Blue, SymbolType.Star);
myCurve.Symbol.Fill = new Fill(Color.White);
myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F);
myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F);
zgc.AxisChange();
zgc.Refresh();
}
Thus is their any way of improving my code so that I can plot 100 points or more per second.