OptionsScales
Namespace: Wisej.Web.Ext.ChartJS3
Assembly: Wisej.Web.Ext.ChartJS3 (4.1.0.0)
Represents the options for the axes (scales) of the chart.
- C#
- VB.NET
public class OptionsScales : OptionsBase
Public Class OptionsScales
Inherits OptionsBase
The axes are exposed as the arrays xAxes and yAxes to support charts with multiple axes. Chart.js 3 expects options.scales to be an object keyed by the scale id: the client script converts the arrays into that object using the keys "x0", "x1", ... for the x-axes and "y0", "y1", ... for the y-axes. An instance is available through the Scales property of the chart options.
Example:
var scales = this.chartJS31.Options.Scales;
scales.xAxes[0].Title.Text = "Month";
scales.yAxes[0].Title.Text = "Revenue";
scales.yAxes[0].Min = 0;
Constructors
OptionsScales()
Default constructor.
Creates a set of scale options that is not attached to any chart yet. It is attached when assigned to Scales.
Example:
var scales = new OptionsScales();
scales.yAxes[0].Max = 100;
this.chartJS31.Options.Scales = scales;
this.chartJS31.Update();
OptionsScales(owner)
Constructs a new instance of the OptionsScales set.
| Name | Type | Description |
|---|---|---|
| owner | OptionsBase | The OptionsBase set of options that owns this instance. |
Throws:
- InvalidOperationException Thrown by the Scales setter when the new instance is owned by a different set of options.
Example:
var options = this.chartJS31.Options;
var scales = new OptionsScales(options);
scales.xAxes[0].Display = false;
options.Scales = scales;
this.chartJS31.Update();
Properties
xAxes
OptionScalesAxesX[]: Options for the x-axes.
Value: An array of OptionScalesAxesX objects, one for each x-axis. When not set, the getter creates an array containing a single default x-axis.
Each axis is sent to Chart.js 3 as options.scales.x0, options.scales.x1, etc., according to its index in the array. To bind a data set to a specific x-axis, set xAxisID to that key. Assigning a new array doesn't update the chart automatically; call Update or the chart's Update() method to refresh it.
Throws:
- ArgumentNullException The value is null.
- InvalidOperationException An axis in the array already belongs to another set of options.
Example:
var xAxis = this.chartJS31.Options.Scales.xAxes[0];
xAxis.Position = HeaderPosition.Top;
xAxis.Grid.Display = false;
xAxis.Title.Text = "Quarter";
this.chartJS31.Update();
yAxes
OptionScalesAxesY[]: Options for the y-axes.
Value: An array of OptionScalesAxesY objects, one for each y-axis. When not set, the getter creates an array containing a single default y-axis.
Each axis is sent to Chart.js 3 as options.scales.y0, options.scales.y1, etc., according to its index in the array. To bind a data set to a specific y-axis, set yAxisID to that key. Assigning a new array doesn't update the chart automatically; call Update or the chart's Update() method to refresh it.
Throws:
- ArgumentNullException The value is null.
- InvalidOperationException An axis in the array already belongs to another set of options.
Example:
var scales = this.chartJS31.Options.Scales;
scales.yAxes = new[]
{
new OptionScalesAxesY { Position = HeaderPosition.Left },
new OptionScalesAxesY { Position = HeaderPosition.Right, Max = 100 }
};
// the second y-axis is registered on the client as "y1".
this.chartJS31.DataSets[1].yAxisID = "y1";
this.chartJS31.Update();