CxJS

Gridlines

import { Gridlines } from 'cx/charts'; Copied

The Gridlines component draws horizontal and vertical gridlines in the chart background. Besides aesthetics, gridlines make it easier to read axis values.

Gridlines automatically align with axis tick marks. Use xAxis and yAxis properties to target different axes or set them to false to hide gridlines in that direction.

<Svg style="width: 400px; height: 300px; border: 1px dashed #ddd">
  <Chart
    margin="40 20 40 50"
    axes={{
      x: <NumericAxis />,
      y: <NumericAxis vertical />,
    }}
  >
    <Rectangle fill="white" />
    <Gridlines />
  </Chart>
</Svg>

Configuration

PropertyTypeDescription
xAxisstring/booleanName of the horizontal axis. Default is "x". Set to false to hide horizontal gridlines.
yAxisstring/booleanName of the vertical axis. Default is "y". Set to false to hide vertical gridlines.
styleobject/stringCustom CSS styles for the gridlines path element.