Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I trying to display the most 'recent' 50 dataPoints on zedGraph. My graph is updating in real-time but I only need to show the 50 points at a time.
Posted
Updated 11-May-11 6:21am
v2

1 solution

Once you reached 50 points, just remove the first point of your curve before adding the new one:
C++
void UpdateGraph(double x, double y)
{
    //get your curve
    CurveItem curve = graphControl1.GraphPane.CurveList[0];
    //if the max size is reached, remove the oldest point
    if (curve.NPts == 50)
        curve.RemovePoint(0);
    //add the new point
    curve.AddPoint(x, y);
    //update the graph
    graphControl1.AxisChange();
}
 
Share this answer
 
Comments
d.allen101 11-May-11 11:56am    
that's what i was looking for! thanks olivier, but now how do i get the graph to 'reformat'? the 50 most recent plots are being displayed in the middle of the graph...it's leaving a gap on the far right hand side of the graph.
Olivier Levrey 11-May-11 12:01pm    
You should set graphControl1.GraphPane.XAxis.Scale.MinAuto and MaxAuto properties to true.
d.allen101 11-May-11 12:00pm    
i think what i trying to ask you is how do get the x-axis to also only show 50 increments so it's in sync with the dataPoints
d.allen101 11-May-11 12:07pm    
never mind olivier, i figured out! thanks for everything!
Olivier Levrey 11-May-11 12:08pm    
Ok good. Don't forget to accept this answer or vote for it ;)

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