shadcn.io is not affiliated with official shadcn/ui
Chart examples · Area
A step area chart for React
An area chart with step interpolation, holding each value flat until the next month.
Use step areas for values that hold until they change, like plan tiers or stock levels. type="step" keeps each month's value flat until the next one, and the tooltip shows the series' icon from the chart config.
Preview
Installation
FAQ
How do I get the stair steps?
Area sets type="step". The value stays flat and then jumps at the next month. dataKey is desktop, fill and stroke are var(--color-desktop), and fillOpacity is 0.4.
Where does the Activity icon show up?
config sets icon to ActivityIcon on desktop. This file has no ChartLegend. ChartTooltipContent draws that icon in the tooltip, in place of the color dot, next to the label Desktop.
Why is the month missing from the tooltip?
ChartTooltipContent sets hideLabel, which hides the tooltip title. XAxis already shows the month. The row is the Activity icon, Desktop, and the value. cursor={false} turns the hover cursor off.
How are the ticks shortened?
XAxis uses dataKey="month" and tickFormatter={formatMonth}, which returns value.slice(0, 3). axisLine and tickLine are false, and tickMargin is 8. CartesianGrid sets vertical={false}.
Related
- A linear area chartAn area chart that joins its monthly
- A simple area chartA single-series area chart with a smooth
- A bar chartA bar chart with rounded corners
- A line chart with stepA line chart with step interpolation
- A stacked area chartAn area chart stacking desktop and mobile
- A radar chartA radar chart plotting one series across