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).
- C#
- VB.NET
public class GridOptions : OptionsBase
Public Class GridOptions
Inherits 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
GridOptions()
Initializes a new instance of GridOptions.
Properties
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;
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" };
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;
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;
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
ResetCircular()
Resets the Circular property to its default value (false).
Example:
var grid = new GridOptions { Circular = true };
grid.ResetCircular();
ResetColor()
Resets the Color property to its default value (null).
Example:
var grid = new GridOptions { Color = "#eeeeee" };
grid.ResetColor();
ResetDisplay()
Resets the Display property to its default value (true).
Example:
var grid = new GridOptions();
grid.ResetDisplay();
ResetDrawBorder()
Resets the DrawBorder property to its default value (true).
Example:
var grid = new GridOptions();
grid.ResetDrawBorder();
ResetLineWidth()
Resets the LineWidth property to its default value (1).
Example:
var grid = new GridOptions { LineWidth = 3 };
grid.ResetLineWidth();
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();
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();
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();
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();
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();