Skip to main content

OptionsLegend

Namespace: Wisej.Web.Ext.ChartJS3

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

Represents the options for the chart legend.

public class OptionsLegend : OptionsBase

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

Example:

var legend = this.chartJS31.Options.Plugins.Legend;
legend.Position = HeaderPosition.Bottom;
legend.Labels.UsePointStyle = true;
legend.Labels.Padding = 20;

Constructors​

Instance member OptionsLegend()​

Default constructor.

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

Example:

var legend = new OptionsLegend();
legend.Position = HeaderPosition.Right;
this.chartJS31.Options.Plugins.Legend = legend;
this.chartJS31.Update();

Instance member OptionsLegend(owner)​

Constructs a new instance of the OptionsLegend set.

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

Example:

var plugins = this.chartJS31.Options.Plugins;
var legend = new OptionsLegend(plugins);
legend.Display = false;
plugins.Legend = legend;

Properties​

Instance member Display​

Boolean: Returns or sets whether the legend is displayed. (Default: True)

Value: The default is true.

Setting this property calls Update to refresh the chart.

Example:

// a chart with a single data set doesn't need a legend.
this.chartJS31.Options.Plugins.Legend.Display = this.chartJS31.DataSets.Count > 1;

Instance member Labels​

OptionsLegendLabels: Returns or sets the options for the labels in the legend.

Value: An OptionsLegendLabels instance; it's created automatically on first access.

Maps to the plugins.legend.labels option of Chart.js 3.

Throws:

Example:

var labels = this.chartJS31.Options.Plugins.Legend.Labels;
labels.BoxWidth = 20;
labels.Color = Color.DimGray;
labels.Font = new Font("Segoe UI", 10F);

Instance member Position​

HeaderPosition: Returns or sets the position of the legend. (Default: Top)

Value: One of the HeaderPosition values. The default is Top.

Setting this property calls Update to refresh the chart.

Example:

// show the legend to the right of a pie chart.
this.chartJS31.ChartType = ChartType.Pie;
this.chartJS31.Options.Plugins.Legend.Position = HeaderPosition.Right;