StackedBar
Barras apiladas para mostrar un total y sus partes en cada periodo. Es BarChart con stacked.
import { BarChart } from '@sypnia/ui/react'
En esta página
Almacenamiento por tipo
Storage by kind
GB, per month
- Database
- Files
- Backups
Ver como tabla
| Database | Files | Backups | |
|---|---|---|---|
| Jul | 12 | 6 | 3 |
| Aug | 14 | 7 | 3 |
| Sep | 17 | 9 | 4 |
| Oct | 19 | 12 | 4 |
| Nov | 23 | 13 | 5 |
Código
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] }]} />;
} Cuándo usarlo
Úsalo cuando
- Totales cuyas partes importan: almacenamiento por tipo.
No lo uses cuando
- Comparar las partes del medio: solo la de abajo empieza en cero.
Para todos
- El tooltip y la tabla dan cada parte en números.
Props
| BarChart | Tipo | Por defecto |
|---|---|---|
seriesobligatorio | Series[] | |
titleobligatorio | ReactNode | |
xobligatorioThe 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 |