Skip to main content

TimeSeriesCollection

Namespace: Wisej.Web.Ext.SmoothieChart

Assembly: Wisej.Web.Ext.SmoothieChart (4.1.0.0)

Represents the collection of TimeSeries lines displayed on the SmoothieChart control.

public class TimeSeriesCollection : IList<TimeSeries>, ICollection<TimeSeries>, IEnumerable<TimeSeries>, IEnumerable, IList, ICollection

Properties​

Instance member Count​

Int32: Returns the number of TimeSeries objects in the collection.

Instance member Item(index)​

TimeSeries: Returns or sets the TimeSeries at the specified index.

Value: The TimeSeries at the specified index.

Replacing an element sends all the lines to the client again, clearing the data points already plotted.

Throws:

Example:

Changing the color of the first line:

this.smoothieChart1.TimeSeries[0] = new TimeSeries { LineColor = Color.Red, LineWidth = 2 };

Methods​

Instance member Add(series)​

Adds a new TimeSeries to the collection.

ParameterTypeDescription
seriesTimeSeriesThe TimeSeries to add to the collection.

All the lines are sent to the client again, clearing the data points already plotted.

Throws:

Example:

Adding a new line:

this.smoothieChart1.TimeSeries.Add(new TimeSeries { LineColor = Color.Yellow });

Instance member Clear()​

Removes all the TimeSeries lines from the collection and updates the chart.

Example:

Replacing all the lines:

this.smoothieChart1.TimeSeries.Clear();
this.smoothieChart1.TimeSeries.Add(new TimeSeries { LineColor = Color.Cyan });

Instance member Contains(series)​

Checks if the specified TimeSeries exists in the collection.

ParameterTypeDescription
seriesTimeSeriesThe TimeSeries to look for.

Returns: Boolean. true if series is found in the collection; otherwise, false.

Example:

Adding a line only once:

if (!this.smoothieChart1.TimeSeries.Contains(this.temperatureLine))
this.smoothieChart1.TimeSeries.Add(this.temperatureLine);

Instance member CopyTo(array, arrayIndex)​

Copies all the TimeSeries lines to the specified array.

ParameterTypeDescription
arrayTimeSeries[]The destination array.
arrayIndexInt32The index in array at which to begin the copy.

Example:

Copying the lines to an array:

var lines = new TimeSeries[this.smoothieChart1.TimeSeries.Count];
this.smoothieChart1.TimeSeries.CopyTo(lines, 0);

Instance member GetEnumerator()​

Returns an enumerator that iterates all the TimeSeries objects in the collection.

Returns: IEnumerator<TimeSeries>. An IEnumerator for the collection.

Example:

Iterating the lines:

foreach (var line in this.smoothieChart1.TimeSeries)
System.Diagnostics.Debug.WriteLine(line.LineColor);

Instance member IndexOf(series)​

Returns the index of the specified TimeSeries in the collection.

ParameterTypeDescription
seriesTimeSeriesThe TimeSeries to look for.

Returns: Int32. The zero-based index of series , or -1 if it's not in the collection.

The index is the value of LineIndex when the DataNeeded event is fired for the line.

Example:

Providing the value of a specific line:

private void smoothieChart1_DataNeeded(object sender, DataNeededEventArgs e)
{
if (e.LineIndex == this.smoothieChart1.TimeSeries.IndexOf(this.temperatureLine))
e.Value = ReadTemperature();
else
e.Value = ReadHumidity();
}

Instance member Insert(index, series)​

Inserts the TimeSeries in the collection at the specified index and updates the chart.

ParameterTypeDescription
indexInt32The index where the new TimeSeries should be inserted.
seriesTimeSeriesThe TimeSeries to insert in the collection.

The index of the lines that follow index changes, and so does the LineIndex used to request their data.

Throws:

Example:

Inserting a line at the top of the collection:

this.smoothieChart1.TimeSeries.Insert(0, new TimeSeries { LineColor = Color.White });

Instance member Remove(series)​

Removes the TimeSeries from the collection and updates the chart.

ParameterTypeDescription
seriesTimeSeriesThe TimeSeries to remove.

Returns: Boolean. true if series was removed; otherwise, false.

Throws:

Example:

Removing a line:

this.smoothieChart1.TimeSeries.Remove(this.temperatureLine);

Instance member RemoveAt(index)​

Removes the TimeSeries at the specified index from the collection and updates the chart.

ParameterTypeDescription
indexInt32The index of the TimeSeries to remove.

Throws:

Example:

Removing the last line:

var lines = this.smoothieChart1.TimeSeries;
if (lines.Count > 0)
lines.RemoveAt(lines.Count - 1);