# Axes and Grid (/docs/charts/building-blocks/axes-grid)

Use `.XAxis`, `.YAxis` and `.Grid` to give a cartesian chart its scales and guide lines, and `.AngleAxis`, `.RadiusAxis` and `.Grid` to do the same for radar and radial charts. They're Recharts' axis and grid components with quieter defaults, and take every Recharts prop.

<Example caption="Hover a topic to see its hours. The dashed line marks the eight-hour target.">
<Basic />

```tsx
"use client";

import { BarChart, type SeriesConfig } from "@kind-ui/charts";

const data = [
  { topic: "Onboarding", hours: 14 },
  { topic: "Security", hours: 9 },
  { topic: "Design reviews", hours: 7 },
  { topic: "Incident drills", hours: 5 },
];

const config = {
  hours: { label: "Hours", color: "#0f8b8d" },
} satisfies SeriesConfig;

export default function WorkshopChart() {
  return (
    <BarChart
      data={data}
      config={config}
      layout="vertical"
      margin={{ right: 16 }}
      aria-label="Workshop hours by topic"
    >
      <BarChart.Grid horizontal={false} vertical />
      <BarChart.XAxis type="number" tickFormatter={(value) => `${value}h`} />
      <BarChart.YAxis type="category" dataKey="topic" width={110} />
      <BarChart.ReferenceLine x={8} stroke="var(--muted-foreground)" strokeDasharray="4 4" />
      <BarChart.Series dataKey="hours" />
      <BarChart.Tooltip />
    </BarChart>
  );
}
```
</Example>

## Usage [#usage]

### Cartesian Axes [#cartesian-axes]

`.XAxis` and `.YAxis` hide the axis and tick lines and draw 12px tick labels in `--muted-foreground`. Pass `axisLine`, `tickLine` or `tick` to bring back or restyle any of them.

Most charts put categories on the X axis with `dataKey`, and numbers on the Y axis. For horizontal bars, swap them: set `layout="vertical"` on the chart, `type="number"` on the X axis and `type="category"` with a `dataKey` on the Y axis, as the example does. Give the Y axis a `width` that fits its longest label.

Use `domain` to fix a numeric range, like `[0, 100]` for scores, and `tickFormatter` to format tick labels:

```tsx
<BarChart.YAxis domain={[0, "auto"]} tickFormatter={(value) => `$${value}k`} />
```

With two scales, give each axis a `yAxisId` and set the same `yAxisId` on its series. [Combo](../components/combo.mdx) charts do this for a bar and a line with different units.

### Grid [#grid]

`.Grid` draws dashed horizontal lines in `--border`. Set `vertical` to add vertical lines and `horizontal={false}` to drop the horizontal ones; `stroke` and `strokeDasharray` restyle them.

### Reference Lines [#reference-lines]

Cartesian charts also have `.ReferenceLine`, `.ReferenceArea` and `.ReferenceDot` to mark a target, a range or a single point, and `.Brush` to pick a range of a long series. They're Recharts' components, so their props follow Recharts.

### Scatter Axes [#scatter-axes]

`ScatterChart.XAxis` and `ScatterChart.YAxis` are numeric by default. `ScatterChart.ZAxis` maps a third value to each point's area, not its radius. Set its `range` and `domain` to keep sizes comparable between charts:

```tsx
<ScatterChart.ZAxis dataKey="requests" range={[40, 320]} domain={[0, 1000]} name="Requests" />
```

### Polar Axes [#polar-axes]

Radar and radial charts use `.AngleAxis` for the categories around the circle, `.RadiusAxis` for the scale out from the center, and `.Grid` for polygon or circular guides. These keep Recharts' own defaults:

```tsx
<RadarChart.AngleAxis dataKey="skill" />
<RadarChart.RadiusAxis domain={[0, 100]} tick={false} axisLine={false} />
<RadarChart.Grid gridType="circle" />
```

<Caption>
Every axis and grid part takes the props of its Recharts component: [XAxis](https://recharts.github.io/en-US/api/XAxis/), [YAxis](https://recharts.github.io/en-US/api/YAxis/), [ZAxis](https://recharts.github.io/en-US/api/ZAxis/), [CartesianGrid](https://recharts.github.io/en-US/api/CartesianGrid/), [PolarAngleAxis](https://recharts.github.io/en-US/api/PolarAngleAxis/), [PolarRadiusAxis](https://recharts.github.io/en-US/api/PolarRadiusAxis/) and [PolarGrid](https://recharts.github.io/en-US/api/PolarGrid/).
</Caption>