Skip to main content

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.

public class OptionsScales : 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​

Instance member 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();

Instance member OptionsScales(owner)​

Constructs a new instance of the OptionsScales set.

NameTypeDescription
ownerOptionsBaseThe OptionsBase set of options that owns this instance.

Throws:

Example:

var options = this.chartJS31.Options;
var scales = new OptionsScales(options);
scales.xAxes[0].Display = false;
options.Scales = scales;
this.chartJS31.Update();

Properties​

Instance member 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:

Example:

var xAxis = this.chartJS31.Options.Scales.xAxes[0];
xAxis.Position = HeaderPosition.Top;
xAxis.Grid.Display = false;
xAxis.Title.Text = "Quarter";
this.chartJS31.Update();

Instance member 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:

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();