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.
- C#
- VB.NET
public class TimeSeriesCollection : IList<TimeSeries>, ICollection<TimeSeries>, IEnumerable<TimeSeries>, IEnumerable, IList, ICollection
Public Class TimeSeriesCollection
Inherits IList(Of TimeSeries)
Implements ICollection(Of TimeSeries), IEnumerable(Of TimeSeries), IEnumerable, IList, ICollection
Properties
Count
Int32: Returns the number of TimeSeries objects in the collection.
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:
- ArgumentOutOfRangeException index is less than 0 or equal to or greater than Count.
Example:
Changing the color of the first line:
this.smoothieChart1.TimeSeries[0] = new TimeSeries { LineColor = Color.Red, LineWidth = 2 };
Methods
Add(series)
Adds a new TimeSeries to the collection.
| Parameter | Type | Description |
|---|---|---|
| series | TimeSeries | The TimeSeries to add to the collection. |
All the lines are sent to the client again, clearing the data points already plotted.
Throws:
- ArgumentNullException series is null.
Example:
Adding a new line:
this.smoothieChart1.TimeSeries.Add(new TimeSeries { LineColor = Color.Yellow });
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 });
Contains(series)
Checks if the specified TimeSeries exists in the collection.
| Parameter | Type | Description |
|---|---|---|
| series | TimeSeries | The 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);
CopyTo(array, arrayIndex)
Copies all the TimeSeries lines to the specified array.
| Parameter | Type | Description |
|---|---|---|
| array | TimeSeries[] | The destination array. |
| arrayIndex | Int32 | The 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);
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);
IndexOf(series)
Returns the index of the specified TimeSeries in the collection.
| Parameter | Type | Description |
|---|---|---|
| series | TimeSeries | The 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();
}
Insert(index, series)
Inserts the TimeSeries in the collection at the specified index and updates the chart.
| Parameter | Type | Description |
|---|---|---|
| index | Int32 | The index where the new TimeSeries should be inserted. |
| series | TimeSeries | The 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:
- ArgumentNullException series is null.
Example:
Inserting a line at the top of the collection:
this.smoothieChart1.TimeSeries.Insert(0, new TimeSeries { LineColor = Color.White });
Remove(series)
Removes the TimeSeries from the collection and updates the chart.
| Parameter | Type | Description |
|---|---|---|
| series | TimeSeries | The TimeSeries to remove. |
Returns: Boolean. true if series was removed; otherwise, false.
Throws:
- ArgumentNullException series is null.
Example:
Removing a line:
this.smoothieChart1.TimeSeries.Remove(this.temperatureLine);
RemoveAt(index)
Removes the TimeSeries at the specified index from the collection and updates the chart.
| Parameter | Type | Description |
|---|---|---|
| index | Int32 | The index of the TimeSeries to remove. |
Throws:
- ArgumentOutOfRangeException index is less than 0 or equal to or greater than Count.
Example:
Removing the last line:
var lines = this.smoothieChart1.TimeSeries;
if (lines.Count > 0)
lines.RemoveAt(lines.Count - 1);