StackedBar
Bars stacked to show a total and its parts in each period. It is BarChart with stacked.
import { BarChart } from '@sypnia/ui/react'
On this page
Storage by kind
Storage by kind
GB, per month
- Database
- Files
- Backups
View as table
| Database | Files | Backups | |
|---|---|---|---|
| Jul | 12 | 6 | 3 |
| Aug | 14 | 7 | 3 |
| Sep | 17 | 9 | 4 |
| Oct | 19 | 12 | 4 |
| Nov | 23 | 13 | 5 |
Code
import { BarChart } from '@sypnia/ui/react';
// Bars stacked to show a total and its parts in each period.
export default function Parts() {
return <BarChart stacked title="Storage by kind" subtitle="GB, per month" x={['Jul', 'Aug', 'Sep', 'Oct', 'Nov']}
series={[{ id: 'db', label: 'Database', data: [12, 14, 17, 19, 23] }, { id: 'files', label: 'Files', data: [6, 7, 9, 12, 13] }, { id: 'backups', label: 'Backups', data: [3, 3, 4, 4, 5] }]} />;
} When to use it
Use it when
- Totals whose parts matter: storage by kind.
Do not use it when
- Comparing the middle parts: only the bottom one starts at zero.
For everyone
- The tooltip and the table give every part in numbers.
Props
| BarChart | 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 | |
stackedSeries on top of each other (parts of a total) instead of side by side. | boolean | false |
subtitle | ReactNode | |
xLabelThe header of the first column of the table view: what `x` is. | string |