Reputation: 1025
I have a method that returns the PointPairList of a graph at time t, but I want to use it to plot a "moving" graph, by "moving" I mean the graph should evolve in time, does anyone have any clue on how I can do this.I tried using RollingPointPairList's but it just doesn't work.
Upvotes: 0
Views: 638
Reputation: 102
what do you mean with evolve? do you want to add points to your curve as time pases, or to change the position of the points that the curve already has?. for the first option i used a timer and a DrawPoint method as handler that adds a point to the curve. the second option could be alittle more complicated, I havent tried to change the Coordinates of one Point, but maybe its posible... it the worst case you will have to delete your old points and draw new ones... anyway here is part of my code to add one point (actually there are many points because i am working with more than 1 curve)
tmr.Interval = 6;
tmr.Tick += new EventHandler(tmr_Tick);
tmrActive = true;
tmr.Start();
void tmr_Tick(object sender, EventArgs e)
{
DrawPoint(zedGraphControl1, points, num); //points is an PointPair array of length num with the new points that i want to add to my Curves(1 point for each Curve)
zedGraphControl1.AxisChange();
zedGraphControl1.Refresh();
if (Start.Enabled == false) Freeze.Enabled = true;
}
private void DrawPoint(ZedGraphControl zgc, PointPair[] p, int num)
{
GraphPane myPane = zgc.GraphPane;
if (myPane.CurveList.Count < num)
{
DrawCurves(zgc, num);
}
for (int i = 0; i < num; i++)
{
myPane.CurveList[i].AddPoint(p[i]);
}
actPos = p[0].X;
mResize(zgc, actPos);
}
Upvotes: 1