BarChart
Compara cantidades entre unas pocas categorías o períodos. Las barras siempre empiezan en cero, así su largo es confiable.
import { BarChart } from '@sypnia/ui/react'
Una serie
New users
Per month, 2026
Ver como tabla
| Month | New users |
|---|---|
| Jan | 212 |
| Feb | 248 |
| Mar | 301 |
| Apr | 290 |
| May | 344 |
| Jun | 402 |
| Jul | 388 |
| Aug | 451 |
| Sep | 520 |
| Oct | 596 |
Código
import { BarChart } from '@sypnia/ui/react';
export default function Signups() {
return (
<BarChart title="New users" subtitle="Per month, 2026" xLabel="Month"
x={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct']}
series={[{ id: 'users', label: 'New users', data: [212, 248, 301, 290, 344, 402, 388, 451, 520, 596] }]} />
);
} Apiladas
Requests by result
Per day, this week. Parts of a total are stacked.
- Succeeded
- Rejected
- Failed
Ver como tabla
| Day | Succeeded | Rejected | Failed |
|---|---|---|---|
| Mon | 8200 | 640 | 90 |
| Tue | 9100 | 700 | 60 |
| Wed | 8800 | 820 | 310 |
| Thu | 9600 | 760 | 120 |
| Fri | 10,4 mil | 910 | 80 |
| Sat | 5200 | 380 | 40 |
| Sun | 4100 | 300 | 30 |
Código
import { BarChart } from '@sypnia/ui/react';
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
export default function Stacked() {
return (
<BarChart stacked title="Requests by result" subtitle="Per day, this week. Parts of a total are stacked." xLabel="Day" x={days}
series={[
{ id: 'ok', label: 'Succeeded', data: [8200, 9100, 8800, 9600, 10400, 5200, 4100] },
{ id: 'client', label: 'Rejected', data: [640, 700, 820, 760, 910, 380, 300] },
{ id: 'server', label: 'Failed', data: [90, 60, 310, 120, 80, 40, 30] },
]} />
);
} Agrupadas
Response time
Milliseconds, by region. Things compared side by side are grouped.
- Typical
- Slowest 5%
Ver como tabla
| Region | Typical | Slowest 5% |
|---|---|---|
| São Paulo | 38 ms | 120 ms |
| Virginia | 24 ms | 88 ms |
| Frankfurt | 31 ms | 96 ms |
| Mumbai | 52 ms | 210 ms |
Código
import { BarChart } from '@sypnia/ui/react';
export default function Grouped() {
return (
<BarChart title="Response time" subtitle="Milliseconds, by region. Things compared side by side are grouped." xLabel="Region" height={220}
x={['São Paulo', 'Virginia', 'Frankfurt', 'Mumbai']} formatValue={(v) => `${v} ms`}
series={[{ id: 'p50', label: 'Typical', data: [38, 24, 31, 52] }, { id: 'p95', label: 'Slowest 5%', data: [120, 88, 96, 210] }]} />
);
} Skeleton
La pieza real y su skeleton: la misma caja, así nada se mueve cuando llegan los datos.
Sign-ups
Per month
Ver como tabla
| Sign-ups | |
|---|---|
| Jul | 120 |
| Aug | 180 |
| Sep | 150 |
| Oct | 240 |
| Nov | 210 |
Sign-ups
Per month
Código
import { BarChart, ChartSkeleton } from '@sypnia/ui/react';
// On the first load a chart can pass `loading` with no data, or the page can draw ChartSkeleton before it knows anything.
export default function Skeleton() {
return (
<div className="sy-grid">
<BarChart title="Sign-ups" subtitle="Per month" x={['Jul', 'Aug', 'Sep', 'Oct', 'Nov']} height={200} series={[{ id: 's', label: 'Sign-ups', data: [120, 180, 150, 240, 210] }]} />
<BarChart title="Sign-ups" subtitle="Per month" x={[]} height={200} series={[]} loading />
</div>
);
} Cuándo usarlo
Úsalo cuando
- Se comparan unas pocas cosas por tamaño: usuarios por mes, tiempo de respuesta por región.
- Partes que suman un total por período: apiladas.
- Dos o tres medidas de la misma unidad, lado a lado: agrupadas (lo normal con varias series).
No lo uses cuando
- Muchos puntos en el tiempo (horas de un día, días de un año): se lee mejor un LineChart.
- Las barras tendrían color según su tamaño. Una serie es un color; el largo ya dice el tamaño.
- Partes de un solo total: usa PartToWhole en vez de una barra apilada o una torta.
Para todos
- Cada barra se alcanza con Tab y anuncia su categoría, su serie y su valor.
- Las barras se separan con espacios del fondo, no con contornos, así se distinguen para todos.
- «Ver como tabla» muestra los mismos números como tabla.
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 |