Skip to content
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
ShowsBubble size: episodes in the archive
Shows by output and listeners
PointGroupEpisodes a monthListeners (k)Size
Morning KopiNews204.2340
Kabar KotaNews226.8410
Dapur KitaLife49.1120
Jalan SoreLife85.4210
Kode SantaiTech212.664
Startup TalkTech67.9150
Bola MalamLife128.3260
  • News
  • Life
  • Tech
  • points is a list of { x, y, size, label, group }. A point with no number for x or y is left out.
  • size makes 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 of BlessChart. A point with no group takes the first chart color.
  • Both axes have round steps that cover the data. x-label and y-label name 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 height sets the height (default 280).
  • The chart is hidden from screen readers, and a table of the points is read in its place. label names the table. format sets the text of a y value and a size, and format-x of an x value. Change the other column names with labels or a label pack: point, group, and size.
  • 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

NameTypeDefaultDescription
points*BlessScatterPoint[]—
groupsBlessScatterGroup[][]the names and colors of the groups, in the order of the legend
xLabelstring"x"the name of each axis, under it and in the table
yLabelstring"y"
heightnumber280
format((v: number) => string)—text for a y value; `formatX` for an x value
formatX((v: number) => string)—
labelstring"Chart"names the chart and its table for screen readers
labelsPartial<{ point: string; group: string; size: string; }>—

Released under the MIT License. Character names and artwork belong to their owners.