OptionsLegend
Namespace: Wisej.Web.Ext.ChartJS
Assembly: Wisej.Web.Ext.ChartJS (4.1.0.0)
Represents the options for the chart legend.
- C#
- VB.NET
public class OptionsLegend : OptionsBase
Public Class OptionsLegend
Inherits OptionsBase
An instance of this class is exposed by Legend and maps to the legend configuration of Chart.js.
Example:
var legend = this.chartJS1.Options.Legend;
legend.Display = true;
legend.Position = HeaderPosition.Bottom;
legend.Labels.UsePointStyle = true;
Constructors
OptionsLegend()
Default constructor.
Creates a set of legend options that is not yet attached to an owner.
Example:
var legend = new OptionsLegend();
legend.Position = HeaderPosition.Bottom;
this.chartJS1.Options.Legend = legend;
OptionsLegend(owner)
Constructs a new instance of the OptionsLegend set.
| Name | Type | Description |
|---|---|---|
| owner | OptionsBase | The OptionsBase instance (usually the chart Options) that owns this set of options. |
Throws:
- InvalidOperationException Thrown when the owner is already assigned to a different instance.
Example:
var options = this.chartJS1.Options;
var legend = new OptionsLegend(options);
legend.Display = false;
options.Legend = legend;
Properties
Display
Boolean: Shows or hides the legend block. (Default: True)
Value: true (default) to show the legend; false to hide it.
Example:
// a single data set doesn't need a legend.
this.chartJS1.Options.Legend.Display = this.chartJS1.DataSets.Count > 1;
Labels
OptionsLegendLabels: Returns or sets the options for the labels in the legend.
Value: An OptionsLegendLabels instance, created automatically on first access.
Throws:
- ArgumentNullException The value is null.
- InvalidOperationException The assigned instance already belongs to a different owner.
Example:
var labels = this.chartJS1.Options.Legend.Labels;
labels.BoxWidth = 20;
labels.Padding = 15;
labels.Font = new Font("Segoe UI", 10F);
Position
HeaderPosition: Returns or sets the position of the legend. (Default: Top)
Value: Either Top (default) or Bottom.
Throws:
- ArgumentException The value is Left or Right.
Example:
this.chartJS1.Options.Legend.Position = HeaderPosition.Bottom;