User (Legacy) Posted January 24, 2003 Report Share Posted January 24, 2003 Hello, I'm attempting to create a scatter plot which updates in real-time as data arrives. I've prototype the following code to update the chart once per second: Dim bufferSize As Integer = 5 Chart1.OpenData(SoftwareFX.ChartFX.COD.Values, 1, bufferSize) Chart1.OpenData(SoftwareFX.ChartFX.COD.XValues, 1, bufferSize) 'Chart1.RealTimeSettings.BufferSize = 100 Dim i As Integer Dim ran As New Random() For i = 0 To bufferSize - 1 Chart1.Value(0, i) = ran.Next(-20, 20) Chart1.XValue(0, i) = ran.Next(-20, 20) Chart1.Update( ) Application.DoEvents() System.Threading.Thread.Sleep(1000) Next Chart1.CloseData(SoftwareFX.ChartFX.COD.Values) Chart1.CloseData(SoftwareFX.ChartFX.COD.XValues) This sample does not update the chart until the CloseData functions are called. If I uncomment the line which specifies RealTimeSettings then I get the following run time exception: OpenData call with COD.XValues required Any suggestions? thanks, Jason Davis Link to comment Share on other sites More sharing options...
Software FX Posted January 25, 2003 Report Share Posted January 25, 2003 Your code is right but the timing in which it is executing is not real-time. The chart will redraw when you yield control, while you are in a loop setting values you have the CPU for yourself and the Chart window won't be painted until you yield control of the CPU. You could add a DoEvents() call inside your loop to force a refresh but I don't think this is what you want to do. Normally, you use a real-time chart when you DON'T have all the data at once, if you have all the data at once, as you have in your example then it is not really a real-time chart. Check out the real-time samples for more details, in the example, a timer is used to indicate a new value is available, in a real-case scenario, this timer could poll some data source or device, or instead of a timer you cod add data as a response from an event sent by the entity in charge of collecting the real-time data. -- FP Software FX, Inc. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.