shadcn.io is not affiliated with official shadcn/ui
Chart examples · Area
A stacked area chart with expand stacking for React
A 100% stacked area chart showing each series' share of the monthly total.
Use it to show how the share of each series changes over time rather than the totals. stackOffset="expand" scales every month to 100%, so the three bands always fill the chart's height.
Preview
Installation
FAQ
How does this chart show share of the month?
AreaChart sets stackOffset="expand". The three areas still use stackId="a", and each month is drawn as one full stack, so the bands are each series' share of that row. type="natural" curves every band.
Which series is on the bottom?
other is the first Area, then mobile, then desktop. With stackId="a", the first area sits on the baseline and the later ones stack above it. Other uses fillOpacity={0.1}. Mobile and desktop use fillOpacity={0.4}.
Where do the three colors come from?
Each Area fills and strokes var(--color-other), var(--color-mobile), or var(--color-desktop). config maps those keys to var(--chart-3), var(--chart-2), and var(--chart-1), with the labels Other, Mobile, and Desktop.
What does the tooltip list?
ChartTooltipContent sets indicator="line" and doesn't set a formatter, so each row is the series label from config and the tooltip's value for that series. cursor={false} turns the hover cursor off. The title is the month.
Related
- A stacked area chartAn area chart stacking desktop and mobile
- A simple area chartA single-series area chart with a smooth
- A stacked bar chart with a legendA bar chart stacking desktop and mobile
- A donut chartA donut chart of visitors by browser, a
- An area chart with axesA stacked area chart with a Y axis
- A radial chart with stacked sectionsA half-circle radial chart stacking