Skip to main content

LegendOptions

Namespace: Wisej.Web.Ext.ChartJS4.Models

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

Represents the configuration of the Chart.js legend plugin (options.plugins.legend), which displays the datasets of the chart and lets the user toggle them.

public class LegendOptions : OptionsBase

An instance is created lazily by Legend. Changing any property updates the chart. Options that are not exposed as properties can be added through ExtensionData.

Example:

var chart = new ChartJS4();
var legend = chart.ChartOptions.Plugins.Legend;
legend.Position = "bottom";
legend.Align = "start";
legend.Labels.UsePointStyle = true;

Constructors​

Instance member LegendOptions()​

Initializes a new instance of LegendOptions.

Properties​

Instance member Align​

String: Returns or sets the alignment of the legend within its box (Chart.js align).

Value: One of "start" | "center" | "end". The default is null, in which case Chart.js uses "center".

Example:

var chart = new ChartJS4();
chart.ChartOptions.Plugins.Legend.Align = "end";

Instance member Display​

Boolean: Returns or sets whether the legend is shown (Chart.js display). (Default: True)

Value: true to show the legend; otherwise false. The default is true.

Example:

var chart = new ChartJS4();
bool legendVisible = chart.ChartOptions.Plugins.Legend.Display;

Instance member FullSize​

Boolean: Returns or sets whether the legend box takes the full width (or height, when placed left or right) of the canvas, moving other boxes aside (Chart.js fullSize). (Default: True)

Value: true to take the full width/height of the canvas; otherwise false. The default is true.

Example:

var chart = new ChartJS4();
bool fullSize = chart.ChartOptions.Plugins.Legend.FullSize;

Instance member Labels​

LegendLabelsOptions: Returns or sets the legend labels configuration (Chart.js labels).

Value: A LegendLabelsOptions instance. The getter creates an empty instance on first access, so nested properties can be set directly.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Plugins.Legend.Labels.BoxWidth = 12;
chart.ChartOptions.Plugins.Legend.Labels.Color = Color.DarkGray;

Instance member MaxHeight​

Int32: Returns or sets the maximum height of the legend, in pixels (Chart.js maxHeight).

Value: The maximum height in pixels. The default is 0, which is not serialized, so Chart.js applies no explicit limit.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Plugins.Legend.MaxHeight = 60;

Instance member MaxWidth​

Int32: Returns or sets the maximum width of the legend, in pixels (Chart.js maxWidth).

Value: The maximum width in pixels. The default is 0, which is not serialized, so Chart.js applies no explicit limit.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Plugins.Legend.Position = "right";
chart.ChartOptions.Plugins.Legend.MaxWidth = 150;

Instance member Position​

String: Returns or sets the position of the legend (Chart.js position).

Value: One of "top" | "left" | "bottom" | "right" | "chartArea". The default is null, in which case Chart.js uses "top".

"chartArea" draws the legend inside the chart area instead of reserving space around it.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Plugins.Legend.Position = "bottom";

Instance member Reverse​

Boolean: Returns or sets whether the legend shows the datasets in reverse order (Chart.js reverse). (Default: False)

Value: true to reverse the order of the legend items; otherwise false. The default is false.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Plugins.Legend.Reverse = true;

Instance member Title​

LegendTitleOptions: Returns or sets the legend title configuration (Chart.js title).

Value: A LegendTitleOptions instance. The getter creates an empty instance on first access, so nested properties can be set directly.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Plugins.Legend.Title.Display = true;
chart.ChartOptions.Plugins.Legend.Title.Text = "Regions";

Methods​

Protected member OnChartChanged()​

Called when the Chart reference changes.

Instance member ResetAlign()​

Resets the Align property to its default value (null).

Used by the designer to restore the default value.

Example:

chart.ChartOptions.Plugins.Legend.ResetAlign();

Instance member ResetDisplay()​

Resets the Display property to its default value (true).

Used by the designer to restore the default value.

Example:

chart.ChartOptions.Plugins.Legend.ResetDisplay();

Instance member ResetFullSize()​

Resets the FullSize property to its default value (true).

Used by the designer to restore the default value.

Example:

chart.ChartOptions.Plugins.Legend.ResetFullSize();

Instance member ResetLabels()​

Resets the Labels property to its default value by discarding the current LegendLabelsOptions instance.

Used by the designer to restore the default value. A new, empty LegendLabelsOptions is created the next time Labels is read.

Example:

chart.ChartOptions.Plugins.Legend.ResetLabels();

Instance member ResetMaxHeight()​

Resets the MaxHeight property to its default value (0).

Used by the designer to restore the default value.

Example:

chart.ChartOptions.Plugins.Legend.ResetMaxHeight();

Instance member ResetMaxWidth()​

Resets the MaxWidth property to its default value (0).

Used by the designer to restore the default value.

Example:

chart.ChartOptions.Plugins.Legend.ResetMaxWidth();

Instance member ResetPosition()​

Resets the Position property to its default value (null).

Used by the designer to restore the default value.

Example:

chart.ChartOptions.Plugins.Legend.ResetPosition();

Instance member ResetReverse()​

Resets the Reverse property to its default value (false).

Used by the designer to restore the default value.

Example:

chart.ChartOptions.Plugins.Legend.ResetReverse();

Instance member ResetTitle()​

Resets the Title property to its default value by discarding the current LegendTitleOptions instance.

Used by the designer to restore the default value. A new, empty LegendTitleOptions is created the next time Title is read.

Example:

chart.ChartOptions.Plugins.Legend.ResetTitle();

Instance member ShouldSerializeAlign()​

Determines whether the Align property should be serialized by the designer.

Returns: Boolean. true if Align is not null; otherwise false.

Used by the designer together with ResetAlign.

Example:

var legend = chart.ChartOptions.Plugins.Legend;
if (legend.ShouldSerializeAlign())
legend.ResetAlign();

Instance member ShouldSerializeDisplay()​

Determines whether the Display property should be serialized by the designer.

Returns: Boolean. true if Display is not true (its default); otherwise false.

Used by the designer together with ResetDisplay.

Example:

var legend = chart.ChartOptions.Plugins.Legend;
if (legend.ShouldSerializeDisplay())
legend.ResetDisplay();

Instance member ShouldSerializeFullSize()​

Determines whether the FullSize property should be serialized by the designer.

Returns: Boolean. true if FullSize is not true (its default); otherwise false.

Used by the designer together with ResetFullSize.

Example:

var legend = chart.ChartOptions.Plugins.Legend;
if (legend.ShouldSerializeFullSize())
legend.ResetFullSize();

Instance member ShouldSerializeLabels()​

Determines whether the Labels property should be serialized by the designer.

Returns: Boolean. true if Labels is not null; otherwise false.

Used by the designer together with ResetLabels. Because the Labels getter creates an instance on demand, this method effectively always returns true.

Example:

var legend = chart.ChartOptions.Plugins.Legend;
if (legend.ShouldSerializeLabels())
legend.ResetLabels();

Instance member ShouldSerializeMaxHeight()​

Determines whether the MaxHeight property should be serialized by the designer.

Returns: Boolean. true if MaxHeight is not 0 (its default); otherwise false.

Used by the designer together with ResetMaxHeight.

Example:

var legend = chart.ChartOptions.Plugins.Legend;
if (legend.ShouldSerializeMaxHeight())
legend.ResetMaxHeight();

Instance member ShouldSerializeMaxWidth()​

Determines whether the MaxWidth property should be serialized by the designer.

Returns: Boolean. true if MaxWidth is not 0 (its default); otherwise false.

Used by the designer together with ResetMaxWidth.

Example:

var legend = chart.ChartOptions.Plugins.Legend;
if (legend.ShouldSerializeMaxWidth())
legend.ResetMaxWidth();

Instance member ShouldSerializePosition()​

Determines whether the Position property should be serialized by the designer.

Returns: Boolean. true if Position is not null; otherwise false.

Used by the designer together with ResetPosition.

Example:

var legend = chart.ChartOptions.Plugins.Legend;
if (legend.ShouldSerializePosition())
legend.ResetPosition();

Instance member ShouldSerializeReverse()​

Determines whether the Reverse property should be serialized by the designer.

Returns: Boolean. true if Reverse is not false (its default); otherwise false.

Used by the designer together with ResetReverse.

Example:

var legend = chart.ChartOptions.Plugins.Legend;
if (legend.ShouldSerializeReverse())
legend.ResetReverse();

Instance member ShouldSerializeTitle()​

Determines whether the Title property should be serialized by the designer.

Returns: Boolean. true if Title is not null; otherwise false.

Used by the designer together with ResetTitle. Because the Title getter creates an instance on demand, this method effectively always returns true.

Example:

var legend = chart.ChartOptions.Plugins.Legend;
if (legend.ShouldSerializeTitle())
legend.ResetTitle();