Skip to the page content

Chart.js

Thirteen charts across the whole library, from pies to live data, each one colored by your theme.

13 charts

Monthly recurring revenue

Pick a range and each point animates to its new value.

Line
More line charts
Show config
chart.data.labels = months.slice(-range);
chart.data.datasets[0].data = mrr.slice(-range);
chart.update();   // animates old points to new

Accounts by plan

248 accounts; a small plugin draws the total.

Doughnut
  • Free 88
  • Basic 74
  • Pro 52
  • Max 34
More doughnuts
Show config
type: 'doughnut',
options: { cutout: '70%' },
plugins: [{ id: 'total', afterDraw(chart) {
  // write the total at the center
} }]

Account health against engagement

One dot per account; the dashed line is the best fit.

Scatter
  • Accounts
  • Trend
More scatter charts
Show config
datasets: [
  { type: 'scatter', data: points },
  { type: 'line', data: [fit(0), fit(40)], borderDash: [6, 5] },
]

Price, margin and sales by product

Price across, margin up, bubble size is units sold.

Bubble
  • Plans
  • Add-ons
  • Services
More scatter charts
Show config
type: 'bubble',
data: { datasets: [{
  label: 'Plans',
  data: [{ x: 16, y: 48, r: 18 }, ...],   // r is in pixels
}] }

Orders shipped per month

The chart reads the table beside it. Change a number and its bar follows.

Bar
Orders shipped per month, April to September
Month Orders
April
May
June
July
August
September
Total 2,823
More bar charts
Show config
const cells = table.querySelectorAll('input');
data: { datasets: [{ data: [...cells].map((c) => +c.value) }] }
table.addEventListener('input', () => { /* copy values */ chart.update(); });

Store revenue by category

Click a category to leave it out of the pie.

Pie
More pie charts
Show config
button.addEventListener('click', () => {
  chart.toggleDataVisibility(index);
  chart.update();
});

Orders per minute, live

A new figure every 2 seconds; pauses when hidden.

Line

9 orders a minute right now

Show config
setInterval(() => {
  if (document.hidden) return;
  chart.data.labels.push(now); chart.data.labels.shift();
  chart.data.datasets[0].data.push(next); chart.data.datasets[0].data.shift();
  chart.update();
}, 2000);

Sessions by channel this week

Hover a day for an HTML tooltip with each share.

Stacked bar
  • Search
  • Direct
  • Email
  • Social
More bar charts
Show config
scales: { x: { stacked: true }, y: { stacked: true } },
plugins: { tooltip: {
  enabled: false,
  external: ({ chart, tooltip }) => { /* fill and place a div */ },
} }

Quarterly review scores

Six areas scored out of 100, this quarter over last.

Radar
  • This quarter
  • Last quarter
More radar charts
Show config
type: 'radar',
options: { scales: { r: { suggestedMin: 50, suggestedMax: 100 } } }

New subscription plans started

A filled line, so each month's size reads first.

Area
More area charts
Show config
datasets: [{ data, fill: 'start', backgroundColor: (ctx) => {
  const g = ctx.chart.ctx.createLinearGradient(0, top, 0, bottom);
  g.addColorStop(0, faded); g.addColorStop(1, clear);
  return g;
} }]

Reviews, returns and tickets

Tiny axis-free lines that sit under a number.

Sparkline

Five-star reviews

32

Returns

6

Support tickets

61

More sparklines
Show config
scales: { x: { display: false }, y: { display: false } },
plugins: { tooltip: { enabled: false } }

People per team

Like a pie, but each slice's radius carries the value.

Polar area
  • Engineering 7
  • Sales 10
  • Operations 11
  • Support 7
  • Product 8
  • Design 10
More polar charts
Show config
type: 'polarArea',
options: { scales: { r: { ticks: { display: false } } } }

Orders placed and repeat orders

Bars for all orders, a line for repeat orders.

Mixed
  • All orders
  • Repeat orders
More mixed charts
Show config
type: 'bar',
data: { datasets: [
  { type: 'bar', label: 'All orders', data: orders },
  { type: 'line', label: 'Repeat orders', data: repeat },
] }

Chart colors

Every chart here takes its colors from these eight tokens.

  • --basalt-series-1
  • --basalt-series-2
  • --basalt-series-3
  • --basalt-series-4
  • --basalt-series-5
  • --basalt-series-6
  • --basalt-series-7
  • --basalt-series-8