Skip to main content

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.

public class LabelCollection : ObservableCollection<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​

Instance member 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;

Instance member LabelCollection(chart)​

Initializes a new empty label collection bound to a chart.

NameTypeDescription
chartChartJS4The owning ChartJS4 control refreshed when the labels change, or null.

Example:

var labels = new LabelCollection(chart);
chart.Labels = labels;

Instance member LabelCollection(items)​

Initializes a new label collection with initial labels.

NameTypeDescription
itemsIEnumerable<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​

Instance member 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​

Protected member ClearItems()​

Protected member InsertItem(index, item)​

ParameterTypeDescription
indexInt32
itemString

Protected member RemoveItem(index)​

ParameterTypeDescription
indexInt32

Protected member SetItem(index, item)​

ParameterTypeDescription
indexInt32
itemString