Ir al contenido

StackedArea

Partes de un total a lo largo del tiempo, una encima de otra: peticiones por respuesta, almacenamiento por tipo. El borde de arriba es el total.

import { StackedArea, ChartSkeleton } from '@sypnia/ui/react'

En esta página
  1. Peticiones por respuesta
  2. Skeleton
  3. Cuándo usarlo
  4. Para todos
  5. Props

Peticiones por respuesta

Requests by answer
Requests per hour, today
  • 2xx answered
  • 3xx redirected
  • 4xx refused
  • 5xx failed
020004000600000:0003:0006:0009:0012:0015:0018:0021:00
Ver como tabla
Hour2xx answered3xx redirected4xx refused5xx failedTotal
00:00132020492121628
01:00136120994121676
02:001481223101121817
03:001671245113122041
04:001920274127122333
05:002209308144122673
06:002520344162123038
07:002831380180123403
08:003120414197123743
09:003369443211124035
10:003559465223124259
11:003679479230124400
12:003720484232124448
13:0036794792301804568
14:0035594654831804687
15:0033694432111804203
16:003120414197123743
17:002831380180123403
18:002520344162123038
19:002209308144122673
20:001920274127122333
21:001671245113122041
22:001481223101121817
23:00136120994121676
Código
import { StackedArea } from '@sypnia/ui/react';

// Parts of a total over time: the top edge is the total. Move the pointer, or focus the chart and use the arrows.
const hours = Array.from({ length: 24 }, (_, h) => `${String(h).padStart(2, '0')}:00`);
const wave = (h: number, base: number, amp: number) => Math.round(base + amp * Math.sin(((h - 6) / 24) * 2 * Math.PI) + amp * 0.6);
export default function Status() {
  return (
    <StackedArea title="Requests by answer" subtitle="Requests per hour, today" xLabel="Hour" x={hours} series={[
      { id: '2xx', label: '2xx answered', data: hours.map((_, h) => wave(h, 1800, 1200)) },
      { id: '3xx', label: '3xx redirected', data: hours.map((_, h) => wave(h, 260, 140)) },
      { id: '4xx', label: '4xx refused', data: hours.map((_, h) => wave(h, 120, 70) + (h === 14 ? 260 : 0)) },
      { id: '5xx', label: '5xx failed', data: hours.map((_, h) => (h >= 13 && h <= 15 ? 180 : 12)) },
    ]} />
  );
}

Skeleton

Almacenamiento por tipo durante un mes, y el gráfico antes de sus datos.

Storage
By kind, November 2026
  • Tables
  • Files
  • Backups
0 GB2.5 GB5 GB7.5 GB10 GBNov 1Nov 5Nov 9Nov 13Nov 17Nov 21Nov 25Nov 29
Ver como tabla
DayTablesFilesBackupsTotal
Nov 12 GB1.2 GB0.8 GB4 GB
Nov 22 GB1.3 GB0.8 GB4.2 GB
Nov 32.1 GB1.4 GB0.9 GB4.4 GB
Nov 42.1 GB1.5 GB0.9 GB4.5 GB
Nov 52.2 GB1.6 GB1 GB4.7 GB
Nov 62.3 GB1.6 GB1 GB4.9 GB
Nov 72.3 GB1.7 GB1 GB5.1 GB
Nov 82.4 GB1.8 GB0.8 GB5 GB
Nov 92.4 GB1.9 GB0.8 GB5.2 GB
Nov 102.5 GB2 GB0.9 GB5.3 GB
Nov 112.5 GB2.1 GB0.9 GB5.5 GB
Nov 122.5 GB2.2 GB1 GB5.7 GB
Nov 132.6 GB2.3 GB1 GB5.9 GB
Nov 142.6 GB2.4 GB1 GB6.1 GB
Nov 152.7 GB2.5 GB0.8 GB6 GB
Nov 162.8 GB2.5 GB0.8 GB6.1 GB
Nov 172.8 GB2.6 GB0.9 GB6.3 GB
Nov 182.9 GB2.7 GB0.9 GB6.5 GB
Nov 192.9 GB2.8 GB1 GB6.7 GB
Nov 203 GB2.9 GB1 GB6.9 GB
Nov 213 GB3 GB1 GB7 GB
Nov 223 GB3.1 GB0.8 GB6.9 GB
Nov 233.1 GB3.2 GB0.8 GB7.1 GB
Nov 243.1 GB3.3 GB0.9 GB7.3 GB
Nov 253.2 GB3.4 GB0.9 GB7.5 GB
Nov 263.3 GB3.5 GB1 GB7.7 GB
Nov 273.3 GB3.5 GB1 GB7.8 GB
Nov 283.4 GB3.6 GB1 GB8 GB
Nov 293.4 GB3.7 GB0.8 GB7.9 GB
Nov 303.5 GB3.8 GB0.8 GB8.1 GB
Código
import { ChartSkeleton, StackedArea } from '@sypnia/ui/react';

// Storage by kind over a month, in gigabytes; and the skeleton the chart has before its data.
const days = Array.from({ length: 30 }, (_, i) => `Nov ${i + 1}`);
export default function Storage() {
  return (
    <div className="sy-stack">
      <StackedArea title="Storage" subtitle="By kind, November 2026" xLabel="Day" x={days} formatValue={(v) => `${Number(v.toFixed(1))} GB`} series={[
        { id: 'tables', label: 'Tables', data: days.map((_, i) => +(2 + i * 0.05).toFixed(2)) },
        { id: 'files', label: 'Files', data: days.map((_, i) => +(1.2 + i * 0.09).toFixed(2)) },
        { id: 'backups', label: 'Backups', data: days.map((_, i) => +(0.8 + (i % 7) * 0.04).toFixed(2)) },
      ]} />
      <ChartSkeleton legend={3} />
    </div>
  );
}

Cuándo usarlo

Úsalo cuando

  • Hasta cinco partes de un total que cambian con el tiempo.
  • Junta la sexta parte y las demás en «Otros»: los colores nunca se repiten ni se inventan.

No lo uses cuando

  • Comparar las partes entre sí: usa LineChart, donde cada una empieza en cero.
  • Valores de distintas unidades: un gráfico para cada uno.

Para todos

  • Enfoca el gráfico y usa las flechas: el tooltip y una línea en vivo leen cada parte y el total.
  • La leyenda nombra cada parte; «Ver como tabla» tiene todos los números.

Props

StackedAreaTipoPor defecto
seriesobligatorio Series[]
titleobligatorio ReactNode
xobligatorio

The positions along the horizontal axis: dates, hours.

string[]
empty ReactNode
error ReactNode
formatValue Fmt
height number
loading boolean
subtitle

What is plotted and in what unit: «Requests per minute, last 24 hours».

ReactNode
xLabel

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

string
ChartSkeletonTipoPor defecto
height number 240
legend

How many series the legend will list.

number 0
table

Whether the chart will offer «View as table» under the plot (every LineChart, AreaChart and BarChart does).

boolean true
  1. Peticiones por respuesta
  2. Skeleton
  3. Cuándo usarlo
  4. Para todos
  5. Props

    Busca páginas, secciones y términos