Skip to content

Grid

Reference

This sample shows how to use scriptable grid options for an axis to control styling. In this case, the Y axis grid lines are colored based on their value. In addition, booleans are provided to toggle different parts of the X axis grid visibility.

1
2
3
4
5
6
7
.Options(o => o
    .Scales(s => s
        .ScaleId("y")
        .BeginAtZero(true)
        .Grid(g => g
            .Color("red")
            .LineWidth(1))))
Grid Line Options:

Circular

If true, gridlines are circular (on radar and polar area charts only). Default false

.Circular(true)

Color

The color of the grid lines. If specified as an array, the first color applies to the first grid line, the second to the second grid line, and so on.

.Color("#666")

Display

If false, do not display grid lines for this axis. Default true

.Display(false)

DrawOnChartArea

If true, draw lines on the chart area inside the axis lines. This is useful when there are multiple axes and you need to control which grid lines are drawn. Default true

.DrawOnChartArea(false)

DrawTicks

If true, draw lines beside the ticks in the axis area beside the chart. Default true

.DrawTicks(true)

LineWidth

Stroke width of grid lines. Default 1

.LineWidth(2)

Offset

If true, grid lines will be shifted to be between labels. This is set to true for a bar chart by default. Default false

.Offset(true)

TickBorderDash

Length and spacing of the tick mark line. If not set, defaults to the grid line borderDash value. Default []

.TickBorderDash(1, 2, 3)

TickBorderDashOffset

Offset for the line dash of the tick mark. If unset, defaults to the grid line 'borderDashOffset' value.

.TickBorderDashOffset(1)

TickColor

Color of the tick line. If unset, defaults to the grid line color.

.TickColor("rgba(0, 0, 0, 0.1)")

TickLength

Length in pixels that the grid lines will draw into the axis area. Default 8

.TickLength(5)

TickWidth

Width of the tick mark in pixels. If unset, defaults to the grid line width.

.TickWidth(1)

Z

z-index of the gridline layer. Values <= 0 are drawn under datasets, > 0 on top. Default -1

.Z(1)