Docs/Cartesian Components/YAxis

YAxis

YAxis renders the vertical axis of a cartesian chart. It is used to display numeric values, with customizable scale, domain, tick marks, and formatting. Multiple YAxis components can be added to compare series with different scales.

import { LineChart, Line, XAxis, YAxis } from "solid-recharts";

<LineChart width={500} height={300} data={data}>
  <XAxis dataKey="name" />
  <YAxis />
  <Line dataKey="uv" stroke="#82ca9d" />
</LineChart>;
YAxis
axes-dual-y.tsxOpen ↗
Loading source...

Props

PropTypeDefaultDescription
orientation"left" | "right""left"Position on the left or right side of the chart
domain[number, number] | ["auto", number] | function[0, "auto"]Min/max scale values; "auto", "dataMin", "dataMax" allowed
widthnumber | "auto"60Fixed width, or "auto" to measure tick labels
yAxisIdstring | number0Unique identifier to bind series to this axis (via yAxisId)
tickFormatter(value) => stringidentityFunction to format tick labels
tickCountnumber5Suggested number of ticks to render
labelstring | object—Axis title, or a <Label> child element
hidebooleanfalseHides the axis, ticks, and labels
type"number" | "category""number"Scale type (numeric or categorical)

All other recharts YAxis props are supported; see the recharts YAxis docs for the complete reference.

Notes

  • The domain prop accepts tuples like [0, 100] (fixed), ["auto", 100] (auto min, fixed max), or a function ([dataMin, dataMax]) => [newMin, newMax] for dynamic adjustment.
  • Use width="auto" to automatically measure the width based on tick label length.
  • To show multiple Y-axes with different scales, assign different yAxisId values and bind each series (Line, Bar, etc.) to its axis via the matching yAxisId.
  • The tickFormatter lets you abbreviate large numbers (e.g. (v) => (v / 1000).toFixed(0) + "k").

See also