Jump to content
Software FX Community

Real time using


User (Legacy)

Recommended Posts

Hi,

I use ChartFX in Realtime mode.

I want to display 1000 samples per seconds, within an 10 second length x axis. (so 10 000 samples)

the X-axis must scroll.

I use the following code but it seems that BufferSize does not give what I expect.

How can I do that ? Do you have any samples to perform such a thing ?

In the following code, if my BufferSize is up to 600, my chart disappear.

Thank you very much,

Best regards,

Sylvain DUISIT

/*******************************************************************************/

Const BufferSize = 100

Dim nOffset As Double

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Set the buffer size to create a Limited Real-time chart.

Chart1.RealTimeSettings.BufferSize = BufferSize

'Initialize the number of points in the chart and assign corresponding labels.

Dim i As Integer

Chart1.OpenData(COD.Values Or COD.Remove Or COD.AllocHidden, 1, BufferSize)

For i = 0 To BufferSize - 1

Chart1.Legend(i) = Str(i / 10)

Next

Chart1.CloseData(COD.Values)

'Set the Max and Min since no data was passed.

Chart1.AxisY.Max = 100

Chart1.AxisY.Min = -100

' Optimize scrolling. These lines will make the chart scroll faster.

Chart1.TypeMask = Chart1.TypeMask Or ChartType.EvenSpacing

Chart1.TypeEx = Chart1.TypeEx Or ChartTypeEx.NoLegInvalidate

Chart1.RealTimeSettings.LoopPos.Color = Color.Transparent

Chart1.RealTimeSettings.Style = RealTimeStyle.NoWaitArrow Or RealTimeStyle.LoopPos

nOffset = 0.0

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Addpoints()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Timer1.Enabled = True

End Sub

Private Sub Addpoints()

'Switch real-time styles once buffer is full

If nOffset = BufferSize Then

Chart1.RealTimeSettings.Style = RealTimeStyle.NoWaitArrow

Chart1.Refresh()

End If

'Set Communication Channel styles

'These COD values instruct Chart FX about the Realtime settings

'the chart, values and legend.

Dim nCOD As SoftwareFX.ChartFX.COD

nCOD = COD.Values Or COD.RealTime

nCOD = nCOD Or COD.ScrollLegend

'Add a point for each sereis to the right of the chart

'Using the legend property, set the legend values

Chart1.OpenData(COD.Values Or COD.AddPoints, 1, 1)

Chart1.Value(0, 0) = -50 + Rnd() * 100

Chart1.Legend(0) = Str(nOffset / 10)

Chart1.CloseData(nCOD)

nOffset = nOffset + 1

End Sub

/*******************************************************************************/

Link to comment
Share on other sites

In the real-time sample provided, has the following line of code:

chart1.TypeMask = chart1.TypeMask | ChartType.EvenSpacing;

This forces even spaced points, which in turn limits the number of points shown in a specific window as the minimum space would be one pixel. For example, if you have 600 points you would need at least 600 pixels to draw them.

If you remove this line of code, the default behavior will assign different spacing depending on available space, 600 point can now fit into 400 pixels by plotting some points in the same x coordinate.

This will make the repaint slower as the chart can not longer be scroll as a picture but gives you much more flexibility.

Another option is to make the chart scrollable and display only a sub-set of points at a time, the scroll view should be less than the buffer size.

--

Francisco Padron

www.chartfx.com

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...