Skip to main content

AxisOptions

Namespace: Wisej.Web.Ext.ChartJS4.Models

Assembly: Wisej.Web.Ext.ChartJS4 (4.1.0.0)

Represents the configuration of a chart axis (scale), serialized as a Chart.js scales[id] entry.

public class AxisOptions : OptionsBase

Instances are lazily created by X and Y. The nested Grid, Border, Title and Ticks options are also created on first access. Scale options not exposed as typed properties (e.g. grace, bounds, time) can be supplied through ExtensionData.

Example:

var chart = new ChartJS4();
var y = chart.ChartOptions.Scales.Y;
y.Type = "linear";
y.Position = "right";
y.SuggestedMin = 0;
y.SuggestedMax = 100;
y.Title.Display = true;
y.Title.Text = "Percent";

Constructors​

Instance member AxisOptions()​

Initializes a new instance of AxisOptions.

Properties​

Instance member Border​

BorderOptions: Returns or sets the options of the axis border line, drawn between the axis and the chart area (Chart.js scales[id].border).

Value: A BorderOptions instance. The getter lazily creates a default instance when none is set.

Changing any of the border values refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.X.Border.Color = System.Drawing.Color.Black;
chart.ChartOptions.Scales.X.Border.Width = 2;

Instance member Display​

Boolean: Returns or sets a value indicating whether the axis is displayed (Chart.js scales[id].display). (Default: True)

Value: true to display the axis; otherwise, false. The default is true.

When hidden, the axis is still used to scale the data. Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
bool axisVisible = chart.ChartOptions.Scales.X.Display;

Instance member Grid​

GridOptions: Returns or sets the grid line options of the axis (Chart.js scales[id].grid).

Value: A GridOptions instance. The getter lazily creates a default instance when none is set.

Changing any of the grid values refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.Grid.Color = "rgba(0, 0, 0, 0.05)";

Instance member Max​

Nullable<Double>: Returns or sets the maximum value of the scale (Chart.js scales[id].max). This user-defined value overrides the maximum value calculated from the data.

Value: The maximum value, or null (default) to calculate it from the data.

Use SuggestedMax instead to extend the range without clipping data. Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.Max = 100;

Instance member Min​

Nullable<Double>: Returns or sets the minimum value of the scale (Chart.js scales[id].min). This user-defined value overrides the minimum value calculated from the data.

Value: The minimum value, or null (default) to calculate it from the data.

Use SuggestedMin instead to extend the range without clipping data. Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.Min = 0;

Instance member Offset​

Boolean: Returns or sets a value indicating whether extra space is added to both edges of the axis so that it is scaled to fit into the chart area (Chart.js scales[id].offset). (Default: False)

Value: true to add the offset; otherwise, false. The default is false.

Chart.js enables the offset by default on the category scale of bar charts. Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.X.Offset = true;

Instance member Position​

Object: Returns or sets the position of the axis (Chart.js scales[id].position).

Value: One of "top", "left", "bottom", "right" or "center"; an object such as { x: 0 } to position the axis at a data value of another axis; or null (default) to use the Chart.js default position.

The property is typed Object so that both string positions and value objects can be assigned. Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.X.Position = "top";
chart.ChartOptions.Scales.Y.Position = new Dictionary<string, object> { { "x", 0 } };

Instance member Reverse​

Boolean: Returns or sets a value indicating whether the scale is reversed (Chart.js scales[id].reverse). (Default: False)

Value: true to reverse the order of the scale values; otherwise, false. The default is false.

Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.Reverse = true;

Instance member Stack​

String: Returns or sets the stack group of the axis (Chart.js scales[id].stack). Axes on the same position with the same stack group are stacked together.

Value: The stack group identifier, or null (default) for no stacking of axes.

Use Weight to order stacked axes. Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.Stack = "demo";

Instance member Stacked​

Object: Returns or sets a value indicating whether the data of the datasets is stacked on this axis (Chart.js scales[id].stacked).

Value: true to stack the datasets, false to not stack them, the string "single" to stack only the datasets with the same stack key, or null (default) to use the Chart.js default.

For stacked bar charts set it on both the X and Y axes. The property is typed Object so that both Boolean values and "single" can be assigned. Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.X.Stacked = true;
chart.ChartOptions.Scales.Y.Stacked = true;

Instance member SuggestedMax​

Nullable<Double>: Returns or sets the suggested maximum value of the scale (Chart.js scales[id].suggestedMax). It is used in the calculation of the scale maximum, but data values above it still extend the scale.

Value: The suggested maximum value, or null (default) for none.

Unlike Max, this value never clips the data. Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.SuggestedMax = 100;

Instance member SuggestedMin​

Nullable<Double>: Returns or sets the suggested minimum value of the scale (Chart.js scales[id].suggestedMin). It is used in the calculation of the scale minimum, but data values below it still extend the scale.

Value: The suggested minimum value, or null (default) for none.

Unlike Min, this value never clips the data. Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.SuggestedMin = -10;

Instance member Ticks​

TickOptions: Returns or sets the options of the axis tick labels (Chart.js scales[id].ticks).

Value: A TickOptions instance. The getter lazily creates a default instance when none is set.

Changing any of the tick values refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.X.Ticks.MaxRotation = 0;
chart.ChartOptions.Scales.Y.Ticks.Color = "#999999";

Instance member Title​

AxisTitleOptions: Returns or sets the options of the axis title (Chart.js scales[id].title).

Value: An AxisTitleOptions instance. The getter lazily creates a default instance when none is set.

The axis title is hidden by default; set Display to true to show it. Changing any of the title values refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.X.Title.Display = true;
chart.ChartOptions.Scales.X.Title.Text = "Year";

Instance member Type​

String: Returns or sets the type of scale being employed (Chart.js scales[id].type).

Value: One of "linear", "logarithmic", "category", "time", "timeseries" or "radialLinear", or null (default) to let Chart.js pick the scale type from the chart type.

The "time" and "timeseries" scales require a date adapter to be loaded in the browser. Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.Type = "logarithmic";

Instance member Weight​

Int32: Returns or sets the weight used to sort the axis (Chart.js scales[id].weight). Higher weights are further away from the chart area.

Value: The sort weight. The default is 0.

Also determines the order of axes within the same Stack group. Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.Weight = 1;

Methods​

Protected member OnChartChanged()​

Called when the Chart reference changes.

Instance member ResetBorder()​

Resets the Border property to its default value by discarding the current BorderOptions instance.

A new default instance is created the next time Border is read.

Example:

var axis = new AxisOptions();
axis.Border.Width = 2;
axis.ResetBorder();

Instance member ResetDisplay()​

Resets the Display property to its default value (true).

Example:

var axis = new AxisOptions();
axis.ResetDisplay();

Instance member ResetGrid()​

Resets the Grid property to its default value by discarding the current GridOptions instance.

A new default instance is created the next time Grid is read.

Example:

var axis = new AxisOptions();
axis.Grid.LineWidth = 2;
axis.ResetGrid();

Instance member ResetMax()​

Resets the Max property to its default value (null).

Example:

var axis = new AxisOptions { Max = 100 };
axis.ResetMax();

Instance member ResetMin()​

Resets the Min property to its default value (null).

Example:

var axis = new AxisOptions { Min = 0 };
axis.ResetMin();

Instance member ResetOffset()​

Resets the Offset property to its default value (false).

Example:

var axis = new AxisOptions { Offset = true };
axis.ResetOffset();

Instance member ResetPosition()​

Resets the Position property to its default value (null).

Example:

var axis = new AxisOptions { Position = "right" };
axis.ResetPosition();

Instance member ResetReverse()​

Resets the Reverse property to its default value (false).

Example:

var axis = new AxisOptions { Reverse = true };
axis.ResetReverse();

Instance member ResetStack()​

Resets the Stack property to its default value (null).

Example:

var axis = new AxisOptions { Stack = "demo" };
axis.ResetStack();

Instance member ResetStacked()​

Resets the Stacked property to its default value (null).

Example:

var axis = new AxisOptions { Stacked = true };
axis.ResetStacked();

Instance member ResetSuggestedMax()​

Resets the SuggestedMax property to its default value (null).

Example:

var axis = new AxisOptions { SuggestedMax = 100 };
axis.ResetSuggestedMax();

Instance member ResetSuggestedMin()​

Resets the SuggestedMin property to its default value (null).

Example:

var axis = new AxisOptions { SuggestedMin = -10 };
axis.ResetSuggestedMin();

Instance member ResetTicks()​

Resets the Ticks property to its default value by discarding the current TickOptions instance.

A new default instance is created the next time Ticks is read.

Example:

var axis = new AxisOptions();
axis.Ticks.MaxRotation = 0;
axis.ResetTicks();

Instance member ResetTitle()​

Resets the Title property to its default value by discarding the current AxisTitleOptions instance.

A new default instance is created the next time Title is read.

Example:

var axis = new AxisOptions();
axis.Title.Text = "Sales";
axis.ResetTitle();

Instance member ResetType()​

Resets the Type property to its default value (null).

Example:

var axis = new AxisOptions { Type = "logarithmic" };
axis.ResetType();

Instance member ResetWeight()​

Resets the Weight property to its default value (0).

Example:

var axis = new AxisOptions { Weight = 2 };
axis.ResetWeight();

Instance member ShouldSerializeBorder()​

Determines whether the Border property should be serialized by the designer.

Returns: Boolean. true if Border is not null; otherwise, false.

Used by the Visual Studio designer together with ResetBorder. Because the Border getter lazily creates an instance, this method currently always returns true.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeBorder())
axis.ResetBorder();

Instance member ShouldSerializeDisplay()​

Determines whether the Display property should be serialized by the designer.

Returns: Boolean. true if Display is not true; otherwise, false.

Used by the Visual Studio designer together with ResetDisplay.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeDisplay())
axis.ResetDisplay();

Instance member ShouldSerializeGrid()​

Determines whether the Grid property should be serialized by the designer.

Returns: Boolean. true if Grid has at least one non-default value; otherwise, false.

Used by the Visual Studio designer together with ResetGrid.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeGrid())
axis.ResetGrid();

Instance member ShouldSerializeMax()​

Determines whether the Max property should be serialized by the designer.

Returns: Boolean. true if Max is not null; otherwise, false.

Used by the Visual Studio designer together with ResetMax.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeMax())
axis.ResetMax();

Instance member ShouldSerializeMin()​

Determines whether the Min property should be serialized by the designer.

Returns: Boolean. true if Min is not null; otherwise, false.

Used by the Visual Studio designer together with ResetMin.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeMin())
axis.ResetMin();

Instance member ShouldSerializeOffset()​

Determines whether the Offset property should be serialized by the designer.

Returns: Boolean. true if Offset is true; otherwise, false.

Used by the Visual Studio designer together with ResetOffset.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeOffset())
axis.ResetOffset();

Instance member ShouldSerializePosition()​

Determines whether the Position property should be serialized by the designer.

Returns: Boolean. true if Position is not null; otherwise, false.

Used by the Visual Studio designer together with ResetPosition.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializePosition())
axis.ResetPosition();

Instance member ShouldSerializeReverse()​

Determines whether the Reverse property should be serialized by the designer.

Returns: Boolean. true if Reverse is true; otherwise, false.

Used by the Visual Studio designer together with ResetReverse.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeReverse())
axis.ResetReverse();

Instance member ShouldSerializeStack()​

Determines whether the Stack property should be serialized by the designer.

Returns: Boolean. true if Stack is not null; otherwise, false.

Used by the Visual Studio designer together with ResetStack.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeStack())
axis.ResetStack();

Instance member ShouldSerializeStacked()​

Determines whether the Stacked property should be serialized by the designer.

Returns: Boolean. true if Stacked is not null; otherwise, false.

Used by the Visual Studio designer together with ResetStacked.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeStacked())
axis.ResetStacked();

Instance member ShouldSerializeSuggestedMax()​

Determines whether the SuggestedMax property should be serialized by the designer.

Returns: Boolean. true if SuggestedMax is not null; otherwise, false.

Used by the Visual Studio designer together with ResetSuggestedMax.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeSuggestedMax())
axis.ResetSuggestedMax();

Instance member ShouldSerializeSuggestedMin()​

Determines whether the SuggestedMin property should be serialized by the designer.

Returns: Boolean. true if SuggestedMin is not null; otherwise, false.

Used by the Visual Studio designer together with ResetSuggestedMin.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeSuggestedMin())
axis.ResetSuggestedMin();

Instance member ShouldSerializeTicks()​

Determines whether the Ticks property should be serialized by the designer.

Returns: Boolean. true if Ticks has at least one non-default value; otherwise, false.

Used by the Visual Studio designer together with ResetTicks.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeTicks())
axis.ResetTicks();

Instance member ShouldSerializeTitle()​

Determines whether the Title property should be serialized by the designer.

Returns: Boolean. true if Title is not null; otherwise, false.

Used by the Visual Studio designer together with ResetTitle. Because the Title getter lazily creates an instance, this method currently always returns true.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeTitle())
axis.ResetTitle();

Instance member ShouldSerializeType()​

Determines whether the Type property should be serialized by the designer.

Returns: Boolean. true if Type is not null; otherwise, false.

Used by the Visual Studio designer together with ResetType.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeType())
axis.ResetType();

Instance member ShouldSerializeWeight()​

Determines whether the Weight property should be serialized by the designer.

Returns: Boolean. true if Weight is not 0; otherwise, false.

Used by the Visual Studio designer together with ResetWeight.

Example:

var axis = new AxisOptions();
if (axis.ShouldSerializeWeight())
axis.ResetWeight();