public void DrawingPulseData(byte[] data)
{
// Make sure that the curvelist has at least one curve
if (PulseControl.GraphPane.CurveList.Count <= 0)
return;
// Get the first CurveItem in the graph
LineItem curve = PulseControl.GraphPane.CurveList[0] as LineItem;
if (curve == null)
return;
// Get the PointPairList
IPointListEdit list = curve.Points as IPointListEdit;
// If this is null, it means the reference at curve.Points does not
// support IPointListEdit, so we won't be able to modify it
if (list == null)
return;
double time = (Environment.TickCount - tickStart) / 1000.0;
for (int i = 0; i < count; i++)
{
list.Add(time, (double)data[i]);
}
Scale xScale = PulseControl.GraphPane.XAxis.Scale;
if (time > xScale.Max - xScale.MajorStep)
{
xScale.Max = time + xScale.MajorStep;
xScale.Min = xScale.Max - 30.0;
}
// Make sure the Y axis is rescaled to accommodate actual data
PulseControl.AxisChange();
// Force a redraw
PulseControl.Invalidate();
count = 0;
}
Hi. I am using this method to draw real time data in zedgraph. count
is length of incoming serial port data. This code works fine in timer(20ms) and draws data at each tick. However if i move this method into a class it does not work correctly. It draws too fast and wrong data.
public static void DrawingPulseData(byte[] data,ZedGraphControl zgc,int count, int TickStart)
I changed parameters like this after moving it into class. I changed PulseControl as zgc, tickstart as TickStart. I could not understand why it is not work same as the first code.
At the first picture,using code provided by @discomurray, i wrote this code statement out of the if's scopes. It gives me data like this.
Scale xScale = zgc.GraphPane.XAxis.Scale;
xScale.Max = now;
xScale.Min = now - 30.0;
If i write the same code statement into if's scopes data looks like picture above. It is a 10 seconds record. I don't have such a data with my method.