Options
Namespace: Wisej.Web.Ext.ChartJS
Assembly: Wisej.Web.Ext.ChartJS (4.1.0.0)
Represents the base options for the ChartJS widget. Different ChartType values extend this class with type specific options.
- C#
- VB.NET
public abstract class Options : OptionsBase
Public MustInherit Class Options
Inherits OptionsBase
The Options property returns the instance of the class that matches the current ChartType: LineOptions, BarOptions (also used for HorizontalBar), PieOptions, PolarAreaOptions, DoughnutOptions, RadarOptions, BubbleOptions or ScatterOptions. Cast it to the specific class to access the type specific options.
Example:
Options options = this.chartJS1.Options;
options.Title.Text = "Revenue";
options.Legend.Display = false;
if (options is LineOptions)
((LineOptions)options).ShowLines = true;
Constructors
Options()
Default constructor.
Used by derived classes to create an option set that is not yet attached to a ChartJS control.
Example:
// derived classes call the default constructor.
Options options = new LineOptions();
options.Title.Text = "Temperatures";
this.chartJS1.Options = options;
Options(chart, defaults)
Constructs a new instance of the Options set.
| Name | Type | Description |
|---|---|---|
| chart | ChartJS | The ChartJS that owns this set of options. |
| defaults | Options | Default options to copy from. Can be null. |
When defaults is not null, the properties shared with it are copied into the new instance. Nested option sets are copied into new instances, other properties are copied only when they have a non-default value.
Example:
// derived classes pass the arguments to the base constructor.
var options = new BarOptions(this.chartJS1, this.chartJS1.Options);
options.Stacked = true;
this.chartJS1.Options = options;
Properties
DataLabel
OptionsDataLabel: Options for the data label.
Value: An OptionsDataLabel instance. It is created automatically the first time the property is read.
Serialized as the dataLabel option of the chart. The data labels are rendered by the chartjs-plugin-datalabels plugin.
Throws:
- ArgumentNullException The value assigned is null.
- InvalidOperationException The OptionsDataLabel instance assigned already belongs to another set of options.
Example:
var dataLabel = this.chartJS1.Options.DataLabel;
dataLabel.Display = true;
dataLabel.Anchor = DataLabelAnchor.End;
dataLabel.Align = DataLabelAlign.Top;
Legend
OptionsLegend: Options for the chart legend.
Value: An OptionsLegend instance. It is created automatically the first time the property is read.
Serialized as the legend option of the chart.
Throws:
- ArgumentNullException The value assigned is null.
- InvalidOperationException The OptionsLegend instance assigned already belongs to another set of options.
Example:
this.chartJS1.Options.Legend.Display = true;
this.chartJS1.Options.Legend.Position = HeaderPosition.Right;
this.chartJS1.Options.Legend.Labels.UsePointStyle = true;
Scales
OptionsScales: Options for the chart scales.
Value: An OptionsScales instance. It is created automatically the first time the property is read.
Serialized as the scales option of the chart.
Throws:
- ArgumentNullException The value assigned is null.
- InvalidOperationException The OptionsScales instance assigned already belongs to another set of options.
Example:
var yAxis = this.chartJS1.Options.Scales.yAxes[0];
yAxis.Ticks.Min = 0;
yAxis.Ticks.Max = 100;
yAxis.GridLines.Display = false;
Title
OptionsTitle: Options for the chart title.
Value: An OptionsTitle instance. It is created automatically the first time the property is read.
Serialized as the title option of the chart.
Throws:
- ArgumentNullException The value assigned is null.
- InvalidOperationException The OptionsTitle instance assigned already belongs to another set of options.
Example:
this.chartJS1.Options.Title.Display = true;
this.chartJS1.Options.Title.Text = "Quarterly Results";
this.chartJS1.Options.Title.Position = HeaderPosition.Bottom;
Tooltips
OptionsTooltips: Options for the chart tooltips.
Value: An OptionsTooltips instance. It is created automatically the first time the property is read.
Serialized as the tooltips option of the chart.
Throws:
- ArgumentNullException The value assigned is null.
- InvalidOperationException The OptionsTooltips instance assigned already belongs to another set of options.
Example:
// hide the tooltips when the user hovers the data points.
this.chartJS1.Options.Tooltips.Enabled = false;
Inherited By
| Name | Description |
|---|---|
| LineOptions | Options for the Line chart. |
| BarOptions | Options for the Bar chart. |
| PieOptions | Options for the Pie chart. |
| PolarAreaOptions | Options for the PolarArea chart. |
| DoughnutOptions | Options for the Doughnut chart. |
| RadarOptions | Options for the Radar chart. |
| BubbleOptions | Options for the Bubble chart. |
| ScatterOptions | Options for the Scatter chart. |