Calm motion: animations on this site only fade, with no movement
Scatter chart
Points on two number axes, or bubbles with a size
Shows how two numbers relate across many items, for example how often a show comes out and how many people listen. A third number can set the size of each dot, which makes a bubble chart. For the spread of one number in groups, use the box plot.
Basic
| Point | Group | Episodes a month | Listeners (k) | Size |
|---|---|---|---|---|
| Morning Kopi | News | 20 | 4.2 | 340 |
| Kabar Kota | News | 22 | 6.8 | 410 |
| Dapur Kita | Life | 4 | 9.1 | 120 |
| Jalan Sore | Life | 8 | 5.4 | 210 |
| Kode Santai | Tech | 2 | 12.6 | 64 |
| Startup Talk | Tech | 6 | 7.9 | 150 |
| Bola Malam | Life | 12 | 8.3 | 260 |
- News
- Life
- Tech
pointsis a list of{ x, y, size, label, group }. A point with no number forxoryis left out.sizemakes a bubble. The area of the dot, not its width, grows with the size, so a bubble twice the size looks twice as big. Big bubbles are drawn first, so a small one is never under a big one.groups({ id, label, color }) gives each group a color, in the same order as the legend ofBlessChart. A point with no group takes the first chart color.- Both axes have round steps that cover the data.
x-labelandy-labelname the axes, under and beside the chart and in the table. - A hover on a dot shows its label and its numbers. The chart draws at the width of its container, and
heightsets the height (default 280). - The chart is hidden from screen readers, and a table of the points is read in its place.
labelnames the table.formatsets the text of a y value and a size, andformat-xof an x value. Change the other column names withlabelsor a label pack:point,group, andsize. - The chart is drawn as plain SVG. There is no chart library to install.
Usage
ts
import { BlessScatterChart, type BlessScatterGroup, type BlessScatterPoint } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
points* | BlessScatterPoint[] | — | |
groups | BlessScatterGroup[] | [] | the names and colors of the groups, in the order of the legend |
xLabel | string | "x" | the name of each axis, under it and in the table |
yLabel | string | "y" | |
height | number | 280 | |
format | ((v: number) => string) | — | text for a y value; `formatX` for an x value |
formatX | ((v: number) => string) | — | |
label | string | "Chart" | names the chart and its table for screen readers |
labels | Partial<{ point: string; group: string; size: string; }> | — |