Angular ChartsAxis Grid Lines
angular logo

Grid lines are horizontal and vertical lines that divide a chart into sections, providing a visual reference for interpreting data.

Enabling Grid Lines

Grid lines are shown by default on number, log and time axes types, and are disabled by default on category axes.

To change this, use the gridLines.enabled property on each axis.

Customising Grid Lines

Grid lines can be styled via the gridLine.style property on each axis.

gridLine: {
    style: [
    {
        stroke: 'gray',
        lineDash: [10, 5],
    },
    {
        stroke: 'lightgray',
        lineDash: [5, 5],
    },
    ],
},

The gridLine.style property takes an array of objects containing two properties:

  • stroke - The colour of the line.
  • lineDash - How the line stroke is rendered. Every number in the array specifies the length in pixels of alternating dashes and gaps. If the array is empty, the grid lines will be solid without any dashes.

Each object in the gridLine.style array is applied to the each grid line sequentially, looping around if necessary. This allows alternating styles across multiple grid lines, or styling each individual grid line separately.

The interval and position of grid lines is controlled by the Axis Ticks.

API Reference

Properties available on the AgAxisGridLineOptions interface.

enabled
Typeboolean
width
TypePixelSize
style
TypeAgAxisGridStyle[]

Next Up

Continue to the next section to learn about Secondary Axes.