LabelCollection
Namespace: Wisej.Web.Ext.ChartJS4.Models
Assembly: Wisej.Web.Ext.ChartJS4 (4.1.0.0)
Observable collection for chart labels that triggers chart updates on changes.
- C#
- VB.NET
public class LabelCollection : ObservableCollection<String>
Public Class LabelCollection
Inherits ObservableCollection(Of [String])
The labels map to the Chart.js data.labels array. Inserting, replacing, removing or clearing labels refreshes the owning Chart. The collection can be assigned from a string[] or a List<string> through the implicit conversion operators.
Example:
chart.Labels = new[] { "Q1", "Q2", "Q3" };
chart.Labels.Add("Q4");
chart.Labels[0] = "First Quarter";
Constructors
LabelCollection()
Initializes a new empty label collection.
The collection is not bound to a chart until it is assigned to Labels.
Example:
var labels = new LabelCollection();
labels.Add("Mon");
chart.Labels = labels;
LabelCollection(chart)
Initializes a new empty label collection bound to a chart.
| Name | Type | Description |
|---|---|---|
| chart | ChartJS4 | The owning ChartJS4 control refreshed when the labels change, or null. |
Example:
var labels = new LabelCollection(chart);
chart.Labels = labels;
LabelCollection(items)
Initializes a new label collection with initial labels.
| Name | Type | Description |
|---|---|---|
| items | IEnumerable<String> | The initial labels, or null to create an empty collection. |
Example:
var months = new List<string> { "Jan", "Feb", "Mar" };
chart.Labels = new LabelCollection(months);
Properties
Chart
ChartJS4: Returns or sets the owning chart.
Value: The ChartJS4 control refreshed when the labels change, or null.
Set automatically when the collection is assigned to Labels.
Example:
chart.Labels = new[] { "A", "B" };
var owner = chart.Labels.Chart; // == chart
Methods
ClearItems()
InsertItem(index, item)
RemoveItem(index)
| Parameter | Type | Description |
|---|---|---|
| index | Int32 |