shadcn.io is not affiliated with official shadcn/ui
Chart examples · Area
A simple area chart for React
A single-series area chart with a smooth curve and a filled area under it.
The starting point for an area chart. One series is drawn as a smooth curve over six months with the area under it filled at 40% opacity, over horizontal grid lines, and the tooltip uses a line indicator.
Preview
Installation
FAQ
How do I get the smooth curve?
Area sets type="natural", dataKey="desktop", fill="var(--color-desktop)", and stroke="var(--color-desktop)". fillOpacity={0.4} fades the area under that stroke. The color comes from config, where desktop is var(--chart-1) and the label is Desktop.
Why do the ticks say Jan?
XAxis uses dataKey="month" and tickFormatter={formatMonth}. formatMonth returns value.slice(0, 3), so January becomes Jan. axisLine and tickLine are false, and tickMargin is 8.
Why are the grid lines only horizontal?
CartesianGrid sets vertical={false}, so only the horizontal lines render. AreaChart sets accessibilityLayer and a margin of left: 12 and right: 12.
What does the tooltip show?
ChartTooltipContent sets indicator="line", a short bar in the series color. With one series, the month sits in that row with the Desktop label and the value. cursor={false} on ChartTooltip turns the hover cursor off.
Related
- A linear area chartAn area chart that joins its monthly
- A stacked area chartAn area chart stacking desktop and mobile
- An area chart with gradient fillA stacked area chart whose areas fade
- A line chartA line chart drawing one series as a
- A bar chartA bar chart with rounded corners
- A step area chartAn area chart with step interpolation