Scatter and bubble chart

Use it to see whether two things move together, such as thread length against cost, and to spot the threads that do not follow the pattern. Add a third measure as bubble size, split the dots into groups, and fit a trend line when the cloud is dense.

← All charts

Live demo

Made-up data. Try the options, then switch to the empty and one-point states.

Tab into the chart, then use the arrow keys to step through the points from left to right (Home and End jump to the ends); Esc closes the tooltip. Hover or touch a dot to read it.

How to use it

Paste the toolkit from Get the code into your page first, then call the chart like this.

JavaScript
const chart = scatter({
  points: threads.map(t => ({
    x: t.questions, y: t.cost, r: t.minutes,
    label: 'Thread ' + t.id, group: t.themeGroup
  })),
  groups: { Renewals: 'var(--c1)', Payments: 'var(--c2)', 'Other themes': 'var(--c9)' },
  trend: true,
  xMax: 30, yMax: 0.4,
  xtitle: 'Questions in the thread',
  ytitle: 'Cost',
  yfmt: v => '£' + (Math.round(v * 100) / 100),
  rtitle: 'Minutes',
  label: 'Thread length against cost'
});
document.querySelector('#host').append(chart);

Options

What you can pass to this chart.

points

[{ x, y, r?, label?, group? }]. r makes it a bubble chart; label is the tooltip title.

groups

{ groupName: colour }. With patterns on, each group also gets its own marker shape.

trend

True to draw a least-squares line (the correlation is on the SVG as data-r).

xMax, yMax

Clip the axes; points beyond are drawn on the edge.

xfmt, yfmt, rfmt, xtitle, ytitle, rtitle

Formatters and axis titles.

maxR, height, colour

Largest bubble radius, chart height and the default dot colour.

label / empty

aria-label for screen readers; text shown when there is no data.

Want charts or dashboards like these in your own product?

Tell me what you are trying to see and I can help work out the right approach, from the data behind it to the screen in front of people.