Note that there are some explanatory texts on larger screens.

plurals
  1. POZedGraph RealTime Data Plotting C#
    text
    copied!<pre><code> public void DrawingPulseData(byte[] data) { // Make sure that the curvelist has at least one curve if (PulseControl.GraphPane.CurveList.Count &lt;= 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 &lt; count; i++) { list.Add(time, (double)data[i]); } Scale xScale = PulseControl.GraphPane.XAxis.Scale; if (time &gt; 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; } </code></pre> <p>Hi. I am using this method to draw real time data in zedgraph. <code>count</code> 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. </p> <pre><code>public static void DrawingPulseData(byte[] data,ZedGraphControl zgc,int count, int TickStart) </code></pre> <p>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.</p> <p><img src="https://i.stack.imgur.com/0oH3q.jpg" alt="enter image description here"></p> <p>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.</p> <pre><code> Scale xScale = zgc.GraphPane.XAxis.Scale; xScale.Max = now; xScale.Min = now - 30.0; </code></pre> <p><img src="https://i.stack.imgur.com/J67i0.jpg" alt="enter image description here"></p> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload