Scatter
Two measures of the same things, one dot each: answer size against time. Each series has its colour and the legend names them.
import { Scatter } from '@sypnia/ui/react'
Size and time of each endpoint
Size and time of each endpoint
- Reads
- Writes
View as table
| 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 |
Code
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 }))} />;
} When to use it
Use it when
- Looking for a relation between two measures.
Do not use it when
- Measures over time: use LineChart.
For everyone
- Each dot is focusable and named with both values; the table lists them all.
- Both axes say what they measure.
Props
| Scatter | Type | Default |
|---|---|---|
pointsrequired | ScatterPoint[] | |
titlerequired | ReactNode | |
xLabelrequired | string | |
yLabelrequired | 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 |