Scatter
Dos medidas de las mismas cosas, un punto cada una: tamaño de la respuesta contra tiempo. Cada serie tiene su color y la leyenda las nombra.
import { Scatter } from '@sypnia/ui/react'
Tamaño y tiempo de cada endpoint
Size and time of each endpoint
- Reads
- Writes
Ver como tabla
| Answer size (kB) | Time (ms) | |
|---|---|---|
| GET /me | 2 | 40 |
| GET /products | 12 | 90 |
| GET /orders | 48 | 210 |
| GET /export | 180 | 640 |
| POST /login | 6 | 120 |
| POST /checkout | 30 | 300 |
| PUT /orders | 90 | 380 |
| GET /tables | 22 | 70 |
Código
import { Scatter } from '@sypnia/ui/react';
// Is a large answer a slow answer? Each dot is an endpoint.
const points = [[2, 40, 'GET /me'], [12, 90, 'GET /products'], [48, 210, 'GET /orders'], [180, 640, 'GET /export'], [6, 120, 'POST /login', 1], [30, 300, 'POST /checkout', 1], [90, 380, 'PUT /orders', 1], [22, 70, 'GET /tables']] as const;
export default function SizeTime() {
return <Scatter title="Size and time of each endpoint" xLabel="Answer size (kB)" yLabel="Time (ms)" series={['Reads', 'Writes']}
points={points.map(([x, y, label, s]) => ({ x, y, label, series: s ?? 0 }))} />;
} Cuándo usarlo
Úsalo cuando
- Buscar una relación entre dos medidas.
No lo uses cuando
- Medidas en el tiempo: usa LineChart.
Para todos
- Cada punto se puede enfocar y se nombra con sus dos valores; la tabla los lista todos.
- Los dos ejes dicen qué miden.
Props
| Scatter | Tipo | Por defecto |
|---|---|---|
pointsobligatorio | ScatterPoint[] | |
titleobligatorio | ReactNode | |
xLabelobligatorio | string | |
yLabelobligatorio | string | |
empty | ReactNode | |
error | ReactNode | |
formatX | Fmt | |
formatY | Fmt | |
height | number | |
loading | boolean | |
seriesNames of the series, in the order of their colours. | string[] | |
subtitle | ReactNode |