AreaChart
A line with a light wash under it, for a quantity that accumulates: storage used, total sign-ups. Two or more series get a legend.
import { AreaChart } from '@sypnia/ui/react'
On this page
Storage used
Storage used
Last 8 weeks
- Database
- Files
View as table
| Week | Database | Files |
|---|---|---|
| W1 | 114 MB | 38 MB |
| W2 | 172 MB | 57 MB |
| W3 | 248 MB | 86 MB |
| W4 | 296 MB | 143 MB |
| W5 | 401 MB | 153 MB |
| W6 | 448 MB | 210 MB |
| W7 | 534 MB | 248 MB |
| W8 | 582 MB | 286 MB |
Code
import { AreaChart, useSypnia } from '@sypnia/ui/react';
// A quantity that accumulates: the wash under the line says «this much, so far».
export default function Storage() {
const { format } = useSypnia();
return <AreaChart title="Storage used" subtitle="Last 8 weeks" xLabel="Week" x={['W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8']}
formatValue={(v) => format.bytes(v * 1e6)} series={[{ id: 'db', label: 'Database', data: [120, 180, 260, 310, 420, 470, 560, 610] }, { id: 'files', label: 'Files', data: [40, 60, 90, 150, 160, 220, 260, 300] }]} />;
} When to use it
Use it when
- Totals that grow over time.
Do not use it when
- Rates and percentages: use LineChart.
- More than three series: the washes cover each other.
For everyone
- Hover or focus to read every series at a point; the table has all the numbers.
Props
| AreaChart | Type | Default |
|---|---|---|
seriesrequired | Series[] | |
titlerequired | ReactNode | |
xrequiredThe positions along the horizontal axis: dates, hours, names. | string[] | |
empty | ReactNode | |
error | ReactNode | |
formatValueHow a value is written in ticks, tooltip and table. Defaults to a compact number in the person's language. | ((v: number) => string) | |
height | number | |
loading | boolean | |
subtitle | ReactNode | |
xLabelThe header of the first column of the table view: what `x` is. | string |