Skip to content

RingBufferChartDataSource

ClassChartGuruChartGuru
public class RingBufferChartDataSource : ChartDataSource

Fixed-capacity streaming source for live values such as frame times or sensor readings. Pushing is thread-safe and O(1); the buffer publishes at most once per frame in LateUpdate. Once the buffer is full the published frame is updated in place, so steady streaming allocates nothing.

The frame has a value column named after RingBufferChartDataSource.SeriesName, plus an X column when samples were pushed with explicit X values; otherwise charts use the sample index.

public const string XColumnName = "X"

Name of the explicit X column.

Returns

System.String

public void Push(float y)

Appends a value; the X position is the sample index.

Parameters

NameType
ySystem.Single
public void Push(float x, float y)

Appends a sample with an explicit X value.

Parameters

NameType
xSystem.Single
ySystem.Single
public void ClearData()

Removes every sample; the next publish hands bound charts an empty frame.

public void SetData(float[] values)

Replaces the buffer with the given values; X is the sample index.

Parameters

NameType
valuesSystem.Single[]
public void SetData(float[] xValues, float[] yValues)

Replaces the buffer with explicit X and Y values.

Parameters

NameType
xValuesSystem.Single[]
yValuesSystem.Single[]
public override void Refresh()

Publishes the current samples immediately.

public RingBufferChartDataSource()

public int Capacity { get; set; }

Maximum number of retained samples.

Returns

System.Int32

public string SeriesName { get; set; }

Name of the value column.

Returns

System.String

public int Count { get; }

Number of samples currently in the buffer.

Returns

System.Int32