import {Chart, ChartGrid, bar} from '@astryxdesign/charts';
<Chart
data={monthlyRevenue}
xKey="month"
series={[bar('revenue')]}
grid={<ChartGrid />}
/>;Chart Grid
ChartGrid draws horizontal and vertical guide lines from the scales owned by a parent Chart. Use it in the Chart grid slot so guides share the plot dimensions and tick values used by the chart.
Authored source examples
Source examples recorded in the documentation for this entry.
<Chart
data={monthlyRevenue}
xKey="month"
series={[bar('revenue')]}
grid={<ChartGrid horizontal vertical tickCount={6} />}
/>;Usage
ChartGrid draws horizontal and vertical guide lines from the scales owned by a parent Chart. Use it in the Chart grid slot so guides share the plot dimensions and tick values used by the chart.
- Pair ChartGrid with ChartAxis when readers need labelled values beside the guide lines.
- Use horizontal guides for value comparison and add vertical guides only when they help readers align categories or continuous x values.
- Use grid lines as the only way to communicate a value or distinction. Keep meaningful chart information in labels, marks, and the parent Chart alternative.
- Expect tickCount to thin categorical band centers. It requests density only for continuous scales; categorical vertical guides render once per band.
Typed props
| Prop | Type and behavior |
|---|---|
horizontal | boolean · default trueWhether to draw horizontal guides at continuous y ticks other than zero. |
vertical | boolean · default falseWhether to draw vertical guides at continuous x ticks or categorical band centers. |
tickCount | number · default 5Approximate guide count requested from continuous scales. It does not thin categorical band centers. |
Anatomy
Horizontal lines at continuous y ticks and vertical lines at x ticks or categorical band centers.
Accessibility
Chart owns the accessible image name and supported small-data table. Grid lines supplement that chart-level alternative rather than replacing it.
Grid lines are supporting guides. Preserve visible labels, marks, or another qualifying cue so understanding does not depend on the grid alone.