Skip to the page content

Scatter & bubble charts

Thirteen ways to plot one number against another with Chart.js, each one colored by your theme.

13 charts

Ten products through the year

Accounts across, weekly use up, MRR as bubble size. Press play.

Bubbles over time

December

$0 MRR

  • Plans
  • Add-ons
  • Integrations
  • Bundles
Show config
type: 'bubble',
data: { datasets: groups.map((g) => ({ label: g, data: pointsFor(g, month) })) },
// On each step, move the same points so Chart.js tweens them:
chart.data.datasets.forEach((ds) => ds.data.forEach((p) => Object.assign(p, at(p.name, month))));
chart.update();

Price against repeat buying

Forty products split at the medians. Top right earn a home-page spot.

Quadrants
Show config
pointBackgroundColor: data.map((p) => colorFor(p.x > midX, p.y > midY)),
plugins: [{ id: 'quadrants', beforeDatasetsDraw(chart) { /* median lines */ } }]

Ad spend and orders

One dot a day, with a least-squares fit.

Trend line
Show config
const { slope, icept, r2 } = leastSquares(points);
datasets.push({ type: 'line', data: [ends], pointRadius: 0 });

Pick a band of deliveries

Drag across the chart, or use the sliders, to pick a distance band.

Range select
  • Parcelwise
  • Northline
  • Swift Post

0 orders

Between 150 and 300 km

Slowest orders in the selected band
Order Km Hours
Show config
canvas.addEventListener('pointerdown', (e) => { from = chart.scales.x.getValueForPixel(e.offsetX); });
canvas.addEventListener('pointermove', (e) => { to = chart.scales.x.getValueForPixel(e.offsetX); chart.update('none'); });
pointBackgroundColor: (c) => inBand(c.raw) ? color : faded

Four kinds of customer

Orders a year against basket. Point at a dot to light its group.

Clusters
Show config
onHover: (e, hits) => { lit = hits.length ? hits[0].datasetIndex : -1; chart.update('none'); },
backgroundColor: (c) => lit < 0 || c.datasetIndex === lit ? color : faded

Customer accounts by city

Visits a week against days to pay. Pick a city to bring it forward.

Highlight one
Show config
datasets.forEach((ds, i) => {
  ds.backgroundColor = i === picked ? accent : faded;
  ds.order = i === picked ? 0 : 1;   // drawn on top
});

Margin, growth and MRR

Each product named in place. Bigger earns more; higher keeps more.

Labeled bubbles
Show config
afterDatasetsDraw(chart) {
  meta.data.forEach((el, i) => ctx.fillText(names[i], el.x + el.options.radius + 6, el.y));
}

Where parcels go

Days to arrive; bubble size is orders.

Bubble size
  • Near the warehouse
  • Across the country
Show config
type: 'bubble',
data: regions.map((r) => ({ x: r.days, y: r.onTime, r: Math.sqrt(r.orders) / 2 }))

Four hundred orders by time of day

Every order last month, half see-through so busy hours build up.

Density
  • Weekday
  • Weekend
Show config
{ pointRadius: 3, pointBackgroundColor: tint(color, 0.28), pointBorderWidth: 0 }

Traffic and conversion, month by month

Each dot is a month, in order. Summer traffic converted less.

Connected
Show config
{ showLine: true, segment: { borderColor: (c) => mix(from, to, c.p1DataIndex / 11) } }

What each carrier costs, and how reliably

Dot is the typical delivery; the bar spans fastest to slowest tenth.

Error bars
Show config
data: carriers.map((c) => ({ x: c.cost, y: c.median, lo: c.p10, hi: c.p90 })),
plugins: [{ id: 'whiskers', beforeDatasetsDraw(chart) { /* line from lo to hi */ } }]

Price and units sold

Log scales, so a $4 SMS pack and a $240 add-on share one chart.

Log scale
  • Plans
  • Add-ons
  • Integrations
  • Bundles
Show config
scales: { x: { type: 'logarithmic' }, y: { type: 'logarithmic' } }

Parcel weight and postage

Forty parcels from last week. Two numbers per dot, nothing else.

Basic
Show config
new Chart(canvas, {
  type: 'scatter',
  data: { datasets: [{ label: 'Parcels', data: [{ x: 1.2, y: 6.4 }, ...] }] },
});