Scatter Chart

View as Markdown

How two measures go together, one dot per thing, in groups, with a third measure as the dot's size.

Accounts by seats and revenue: Yearly revenue against Seats.
PointGroupSeatsYearly revenue
NorthwindTeam42$18,400.00
InitechTeam18$6,200.00
VandelayTeam12$3,900.00
SoylentTeam28$9,100.00
WonkaTeam8$2,600.00
Dunder MifflinTeam34$8,700.00
Pied PiperTeam22$12,900.00
GlobexBusiness120$61,000.00
HooliBusiness85$29,500.00
AcmeBusiness64$34,800.00
CyberdyneBusiness96$41,200.00
GringottsBusiness58$39,600.00
UmbrellaEnterprise260$148,000.00
Stark IndustriesEnterprise310$205,000.00
Wayne EnterprisesEnterprise190$96,000.00
TyrellEnterprise150$118,000.00
OscorpEnterprise220$102,500.00
Massive DynamicEnterprise270$171,000.00

When to use

How two measures go together, one dot per thing, in groups, with a third measure as the dot's size. Use Line Chart instead when one measure changes over time.

Usage

import { ScatterChart } from "./ui/uicontext/components/charts/Scatter.ts"
export const Deals = <M>(h: Html.H<M>) =>	ScatterChart(h, {		props: {			label: "Deals",			x: { label: "Days to close" },			y: { label: "Deal size", format: { style: "currency", currency: "USD" } },			series: [{ id: "won", label: "Won", points: [{ id: "a", label: "Acme", x: 21, y: 12_000 }, { id: "b", label: "Globex", x: 64, y: 48_000 }] }],		},		onEmit: { Highlighted: () => undefined, Selected: () => undefined, RequestedRetry: () => undefined },	})

Examples

Sized by a third measure

size draws each dot's area from a third value, here visits; the tooltip and table name it.

Pages by load time and bounce rate: Bounce rate against Load time.
NameLoad timeBounce rateVisits
/1.1 sec32%48,200
/pricing1.6 sec41%21,400
/docs0.9 sec22%33,900
/blog2.8 sec63%12,100
/signup1.3 sec28%9,800
/changelog2.1 sec47%4,300
/customers3.4 sec71%3,100
/careers2.5 sec58%2,200
/integrations1.9 sec36%7,600
/security1.4 sec31%2,900
/status0.7 sec18%6,400
/contact1.2 sec44%3,700

API reference

Props

ScatterChart props
NameTypeDefaultDescription
labelrequiredstring——
seriesrequiredScatterSeries[]——
xrequiredScatterAxis——
yrequiredScatterAxis——
size{ label, format }—What size measures, for the tooltip and the table: { label: "Deals", format }
heightnumber300Pixels; 300 by default
tableToggleboolean——
statusChartStatus——
errorstring——
emptyTextstring—What nothing-to-show means here
localestring——

Events

ScatterChart events
EventPayloadDescription
Highlighted{ series: string | null; point: string | null }The dot being read, by pointer or keys; null when none
Selected{ series: string; point: string }—
RequestedRetry{}—

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/scatter-chart

Source