OptionsLegendLabels
Namespace: Wisej.Web.Ext.ChartJS
Assembly: Wisej.Web.Ext.ChartJS (4.1.0.0)
Represents the options for the labels in the chart legend.
- C#
- VB.NET
public class OptionsLegendLabels : OptionsBase
Public Class OptionsLegendLabels
Inherits OptionsBase
An instance of this class is exposed by Labels and maps to the legend.labels configuration of Chart.js.
Example:
var labels = this.chartJS1.Options.Legend.Labels;
labels.UsePointStyle = true;
labels.Padding = 20;
Constructors
OptionsLegendLabels()
Default constructor.
Creates a set of legend label options that is not yet attached to an owner.
Example:
var labels = new OptionsLegendLabels();
labels.BoxWidth = 12;
this.chartJS1.Options.Legend.Labels = labels;
OptionsLegendLabels(owner)
Constructs a new instance of the OptionsLegendLabels set.
| Name | Type | Description |
|---|---|---|
| owner | OptionsBase | The OptionsBase instance (usually the OptionsLegend) that owns this set of options. |
Throws:
- InvalidOperationException Thrown when the owner is already assigned to a different instance.
Example:
var legend = this.chartJS1.Options.Legend;
var labels = new OptionsLegendLabels(legend);
labels.UsePointStyle = true;
legend.Labels = labels;
Properties
BoxWidth
Int32: Returns or sets the width of the colored box. (Default: 40)
Value: The width in pixels. The default is 40.
Example:
// small square markers.
this.chartJS1.Options.Legend.Labels.BoxWidth = 12;
Color
Color: Returns or sets the color of the legend labels. (Default: Color [Empty])
Value: The default is Empty.
The value is sent to the client as the legend.labels.color option.
Example:
this.chartJS1.Options.Legend.Labels.Color = Color.DarkSlateGray;
Font
Font: Returns or sets the font of the legend labels. (Default: null)
Value: When not set (null), returns the Font of the owner ChartJS control.
The font is converted on the client to the Chart.js fontSize, fontFamily and fontStyle options.
Example:
this.chartJS1.Options.Legend.Labels.Font = new Font("Arial", 11F, FontStyle.Bold);
Padding
Int32: Returns or sets the padding between labels (rows of colored boxes). (Default: 10)
Value: The padding in pixels. The default is 10.
Example:
this.chartJS1.Options.Legend.Labels.Padding = 20;
UsePointStyle
Boolean: Returns or sets whether the legend uses the point style of each dataset instead of a rectangle to identify it. (Default: False)
Value: The default is false.
When true, the size of the legend marker is based on the font size instead of BoxWidth.
Example:
this.chartJS1.ChartType = ChartType.Line;
this.chartJS1.Options.Legend.Labels.UsePointStyle = true;