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.
- C#
- VB.NET
public class AxisOptions : OptionsBase
Public Class AxisOptions
Inherits 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
AxisOptions()
Initializes a new instance of AxisOptions.
Properties
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;
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;
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)";
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;
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;
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;
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 } };
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;
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";
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;
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;
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;
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";
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";
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";
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
OnChartChanged()
Called when the Chart reference changes.
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();
ResetDisplay()
Resets the Display property to its default value (true).
Example:
var axis = new AxisOptions();
axis.ResetDisplay();
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();
ResetMax()
Resets the Max property to its default value (null).
Example:
var axis = new AxisOptions { Max = 100 };
axis.ResetMax();
ResetMin()
Resets the Min property to its default value (null).
Example:
var axis = new AxisOptions { Min = 0 };
axis.ResetMin();
ResetOffset()
Resets the Offset property to its default value (false).
Example:
var axis = new AxisOptions { Offset = true };
axis.ResetOffset();
ResetPosition()
Resets the Position property to its default value (null).
Example:
var axis = new AxisOptions { Position = "right" };
axis.ResetPosition();
ResetReverse()
Resets the Reverse property to its default value (false).
Example:
var axis = new AxisOptions { Reverse = true };
axis.ResetReverse();
ResetStack()
Resets the Stack property to its default value (null).
Example:
var axis = new AxisOptions { Stack = "demo" };
axis.ResetStack();
ResetStacked()
Resets the Stacked property to its default value (null).
Example:
var axis = new AxisOptions { Stacked = true };
axis.ResetStacked();
ResetSuggestedMax()
Resets the SuggestedMax property to its default value (null).
Example:
var axis = new AxisOptions { SuggestedMax = 100 };
axis.ResetSuggestedMax();
ResetSuggestedMin()
Resets the SuggestedMin property to its default value (null).
Example:
var axis = new AxisOptions { SuggestedMin = -10 };
axis.ResetSuggestedMin();
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();
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();
ResetType()
Resets the Type property to its default value (null).
Example:
var axis = new AxisOptions { Type = "logarithmic" };
axis.ResetType();
ResetWeight()
Resets the Weight property to its default value (0).
Example:
var axis = new AxisOptions { Weight = 2 };
axis.ResetWeight();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
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();