Ir al contenido

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'

En esta página
  1. Una serie
  2. Apiladas
  3. Agrupadas
  4. Skeleton
  5. Cuándo usarlo
  6. Para todos
  7. Props

Una serie

New users
Per month, 2026
0200400600JanMarMayJulSep
Ver como tabla
MonthNew users
Jan212
Feb248
Mar301
Apr290
May344
Jun402
Jul388
Aug451
Sep520
Oct596
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
0500010 mil15 milMonTueWedThuFriSatSun
Ver como tabla
DaySucceededRejectedFailed
Mon820064090
Tue910070060
Wed8800820310
Thu9600760120
Fri10,4 mil91080
Sat520038040
Sun410030030
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%
0 ms100 ms200 ms300 msSão PauloVirginiaFrankfurtMumbai
Ver como tabla
RegionTypicalSlowest 5%
São Paulo38 ms120 ms
Virginia24 ms88 ms
Frankfurt31 ms96 ms
Mumbai52 ms210 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
0100200300JulAugSepOctNov
Ver como tabla
Sign-ups
Jul120
Aug180
Sep150
Oct240
Nov210
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

BarChartTipoPor defecto
seriesobligatorio Series[]
titleobligatorio ReactNode
xobligatorio

The positions along the horizontal axis: dates, hours, names.

string[]
empty ReactNode
error ReactNode
formatValue

How 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
stacked

Series on top of each other (parts of a total) instead of side by side.

boolean false
subtitle ReactNode
xLabel

The header of the first column of the table view: what `x` is.

string
  1. Una serie
  2. Apiladas
  3. Agrupadas
  4. Skeleton
  5. Cuándo usarlo
  6. Para todos
  7. Props

    Busca páginas, secciones y términos