shadcn.io is not affiliated with official shadcn/ui
About
Use it when people read numbers off the chart: a report, a shared screen, a printout where nothing can be hovered. The other area charts drop the value axis to keep the card quiet; this one shows three labeled values. If people need every exact number, add a table under it.
Mobile and desktop stack as smooth curves at 40% fill. On the left, the value axis prints 0, 300 and 600 with no line or tick marks, and the months run along the bottom, cut to three letters.
Installation
Usage
import { ChartAreaAxes } from "@/components/charts/chart-area-axes";<ChartAreaAxes />Customize
<YAxis axisLine={false} tickLine={false} tickMargin={8} tickCount={3} />adds the value axis with three labels.- The chart's
marginsetsleft: -20to pull the labels into the card's padding. - A
tickFormatteron<YAxis>would format each value;<XAxis>uses one to cut the months to three letters. - Both
<Area>s sharestackId="a", so the axis measures the stacked total.
FAQ
How do I change how many values the axis shows?
Set tickCount on <YAxis>: 3 here. Recharts rounds to tidy values; pass ticks={[0, 300, 600]} for exact ones.
How do I format the values as currency or thousands?
Pass tickFormatter to <YAxis>. It receives each value and returns the label, for example through Intl.NumberFormat with notation: "compact" for 1.2K.
Why does the axis stop at 600?
Recharts takes the domain from the stacked data and rounds it for three ticks. Set domain={[0, 600]} on <YAxis> to fix it.
Can the axis go on the right?
Set orientation="right" on <YAxis> and move the negative margin to right so the labels sit in the card's padding.
API Reference
ChartContainer
configChartConfig
Each series by its data key: its label, an icon, and a color (or a * theme color per light and dark), read by the tooltip and legend and set * as --color-<key>.
initialDimension?{ height: number; width: number; }
The size it renders at before it's measured, so the first paint isn't * empty.
- Type
{ height: number; width: number; }- Default
INITIAL_DIMENSION
className?string
Merged with the part's classes.
ChartLegend
ChartLegendContent
<div>
hideIcon?boolean
Hides each series' icon (from config), leaving its color swatch.
- Default
false
nameKey?string
The key in each legend item's data to look its label up by in config. * Defaults to the item's dataKey.
className?string
Merged with the part's classes.
ChartStyle
<style>
configChartConfig
The chart config whose colors it writes as --color-<key> variables.
idstring
The element's id.
ChartTooltip
ChartTooltipContent
<div>
hideIndicator?boolean
Hides each item's color indicator.
- Default
false
hideLabel?boolean
Hides the tooltip's label, the hovered point's.
- Default
false
indicator?"dashed" | "dot" | "line"
The color indicator's shape: a dot, a line or dashed.
- Type
"dashed" | "dot" | "line"- Default
"dot"
labelFormatter?(label: any, payload: TooltipPayload) → React.ReactNode
Formats the tooltip's label; its value is untyped, as in recharts 3.8.
- Type
(label: any, payload: TooltipPayload) → React.ReactNode- Parameters
label– anypayload– TooltipPayload- Returns
React.ReactNode
labelKey?string
The key in the data to read the label from, looked up in config.
nameKey?string
The key in each item's data to look its name up by in config.
className?string
Merged with the part's classes.
Related
Stacked Area Chart
Area chartsTwo series stacked into one total, each band its own color.
Area Chart
Area chartsOne series as a smooth filled curve over six months.
Multiple Line Chart
Line chartsTwo series as lines on the same axes.
Multiple Bar Chart
Bar chartsTwo series grouped side by side for each month.
Radar Chart with Radius Axis
Radar chartsA radar with its radius axis and values drawn on a spoke.
Expanded Stacked Area Chart
Area chartsStacked areas expanded to 100%, so each band reads as a share.