Skip to main content

OptionsLegendLabels

Namespace: Wisej.Web.Ext.ChartJS3

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

Represents the options for the labels in the chart legend.

public class OptionsLegendLabels : OptionsBase

An instance of this class is exposed by the Labels property and maps to the plugins.legend.labels configuration of Chart.js 3.

Example:

var labels = this.chartJS31.Options.Plugins.Legend.Labels;
labels.UsePointStyle = true;
labels.Padding = 15;
labels.Color = Color.Navy;

Constructors​

Instance member OptionsLegendLabels()​

Default constructor.

Creates a set of legend label options that is not attached to an owner.

Example:

var labels = new OptionsLegendLabels();
labels.BoxWidth = 12;
this.chartJS31.Options.Plugins.Legend.Labels = labels;
this.chartJS31.Update();

Instance member OptionsLegendLabels(owner)​

Constructs a new instance of the OptionsLegendLabels set.

NameTypeDescription
ownerOptionsBaseThe OptionsBase instance (usually the OptionsLegend) that owns this set of options.

Example:

var legend = this.chartJS31.Options.Plugins.Legend;
var labels = new OptionsLegendLabels(legend);
labels.UsePointStyle = true;
legend.Labels = labels;

Properties​

Instance member BoxWidth​

Int32: Returns or sets the width of the colored box. (Default: 40)

Value: The width in pixels. The default is 40.

Setting this property calls Update to refresh the chart.

Example:

// small square boxes.
this.chartJS31.Options.Plugins.Legend.Labels.BoxWidth = 12;

Instance member Color​

Color: Returns or sets the color of the legend label text. (Default: Color [Empty])

Value: The default is Empty, which uses the Chart.js default color.

Setting this property calls Update to refresh the chart.

Example:

this.chartJS31.BackColor = Color.FromArgb(33, 33, 33);
this.chartJS31.Options.Plugins.Legend.Labels.Color = Color.WhiteSmoke;

Instance member Font​

Font: Returns or sets the font of the legend labels. (Default: null)

Value: When not set (null), returns the Font of the chart control.

Setting this property calls Update to refresh the chart.

Example:

this.chartJS31.Options.Plugins.Legend.Labels.Font = new Font("Arial", 12F, FontStyle.Italic);

Instance member Padding​

Int32: Returns or sets the padding between the legend labels (rows of colored boxes). (Default: 10)

Value: The padding in pixels. The default is 10.

Setting this property calls Update to refresh the chart.

Example:

var legend = this.chartJS31.Options.Plugins.Legend;
legend.Position = HeaderPosition.Left;
legend.Labels.Padding = 25;

Instance member UsePointStyle​

Boolean: Returns or sets whether the legend uses the point style of each data set instead of a rectangle to identify it. (Default: False)

Value: The default is false.

The symbol is taken from the point style of the data set (for example PointStyle) and its size is based on the font size. Setting this property calls Update to refresh the chart.

Example:

var dataSet = (LineDataSet)this.chartJS31.DataSets[0];
dataSet.PointStyle = new[] { PointStyle.Triangle };
this.chartJS31.Options.Plugins.Legend.Labels.UsePointStyle = true;