Skip to main content

GridOptions

Namespace: Wisej.Web.Ext.ChartJS4.Models

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

Represents the grid line options of an axis (Chart.js scales[id].grid).

public class GridOptions : OptionsBase

An instance is lazily created by Grid. Additional Chart.js grid options, such as drawOnChartArea, drawTicks, tickLength or offset, can be supplied through ExtensionData.

Example:

var chart = new ChartJS4();
var grid = chart.ChartOptions.Scales.Y.Grid;
grid.Color = "rgba(0, 0, 0, 0.1)";
grid.LineWidth = 2;

Constructors​

Instance member GridOptions()​

Initializes a new instance of GridOptions.

Properties​

Instance member Circular​

Boolean: Returns or sets a value indicating whether the grid lines are circular (Chart.js grid.circular). (Default: False)

Value: true to draw circular grid lines; otherwise, false to draw polygonal lines. The default is false.

Applies only to radial scales (radar and polar area charts). Setting this property refreshes the chart.

Example:

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

Instance member Color​

Object: Returns or sets the color of the grid lines (Chart.js grid.color).

Value: A Color, a CSS color string, or an array of colors (the first color is applied to the first grid line, the second to the second, and so on), or null (default) to use the Chart.js default color.

Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.Grid.Color = System.Drawing.Color.LightGray;
chart.ChartOptions.Scales.X.Grid.Color = new[] { "red", "green", "blue" };

Instance member Display​

Boolean: Returns or sets a value indicating whether the grid lines of the axis are drawn (Chart.js grid.display). (Default: True)

Value: true to draw the grid lines; otherwise, false. The default is true.

Setting this property refreshes the chart.

Example:

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

Instance member DrawBorder​

Boolean: Returns or sets a value indicating whether a border is drawn at the edge between the axis and the chart area (Chart.js 3 grid.drawBorder). (Default: True)

Value: true to draw the border; otherwise, false. The default is true.

In Chart.js 4 this option was replaced by border.display; use Border and Display to control the axis border. Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
bool drawBorder = chart.ChartOptions.Scales.X.Grid.DrawBorder;

Instance member LineWidth​

Int32: Returns or sets the stroke width of the grid lines, in pixels (Chart.js grid.lineWidth). (Default: 1)

Value: The grid line width in pixels. The default is 1.

Setting this property refreshes the chart.

Example:

var chart = new ChartJS4();
chart.ChartOptions.Scales.Y.Grid.LineWidth = 2;

Methods​

Instance member ResetCircular()​

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

Example:

var grid = new GridOptions { Circular = true };
grid.ResetCircular();

Instance member ResetColor()​

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

Example:

var grid = new GridOptions { Color = "#eeeeee" };
grid.ResetColor();

Instance member ResetDisplay()​

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

Example:

var grid = new GridOptions();
grid.ResetDisplay();

Instance member ResetDrawBorder()​

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

Example:

var grid = new GridOptions();
grid.ResetDrawBorder();

Instance member ResetLineWidth()​

Resets the LineWidth property to its default value (1).

Example:

var grid = new GridOptions { LineWidth = 3 };
grid.ResetLineWidth();

Instance member ShouldSerializeCircular()​

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

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

Used by the Visual Studio designer together with ResetCircular.

Example:

var grid = new GridOptions();
if (grid.ShouldSerializeCircular())
grid.ResetCircular();

Instance member ShouldSerializeColor()​

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

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

Used by the Visual Studio designer together with ResetColor.

Example:

var grid = new GridOptions();
if (grid.ShouldSerializeColor())
grid.ResetColor();

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 grid = new GridOptions();
if (grid.ShouldSerializeDisplay())
grid.ResetDisplay();

Instance member ShouldSerializeDrawBorder()​

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

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

Used by the Visual Studio designer together with ResetDrawBorder.

Example:

var grid = new GridOptions();
if (grid.ShouldSerializeDrawBorder())
grid.ResetDrawBorder();

Instance member ShouldSerializeLineWidth()​

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

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

Used by the Visual Studio designer together with ResetLineWidth.

Example:

var grid = new GridOptions();
if (grid.ShouldSerializeLineWidth())
grid.ResetLineWidth();