Skip to the page content

Area charts

Thirteen ways to fill the space under a line with Chart.js, each one colored by your theme.

13 charts

MRR by plan

Stacked, so the top edge is the total and each band one plan.

Stacked
  • Basic
  • Pro
  • Max
  • Add-ons
Show config
datasets: categories.map((c, i) => ({ label: c.name, data: c.data, fill: i ? '-1' : 'origin' })),
options: { scales: { y: { stacked: true } } }

Where orders come from

Each month is 100%, so only the mix moves.

100% stacked
  • Search
  • Direct
  • Email
  • Social
Show config
// Each month is turned into shares that add up to 100.
const share = (i) => (v) => (v / totals[i]) * 100;
scales: { y: { stacked: true, min: 0, max: 100 } }

Accounts at a glance

Small filled shapes with no axes, weighty enough to read at a glance.

Sparklines

Active accounts

2,140

Up 122 in 12 weeks

Visits booked

41.2k

This week

Weekly churn

1.1%

Falling since week 3

MRR per account

$411

Add-ons included

Show config
{ fill: 'start', backgroundColor: fadeDown(color), pointRadius: 0 },
options: { scales: { x: { display: false }, y: { display: false } } }

Net cash each week

Fill turns color in weeks that lost money.

Above and below zero
  • Cash in hand
  • Cash spent
Show config
fill: { target: 'origin', above: tint(success, .3), below: tint(danger, .3) }

Time from order to shipping

The band spans fastest to slowest order; the line is the typical one.

Range band
  • Fastest to slowest
  • Typical order
Show config
{ label: 'Slowest', data: slowest, pointRadius: 0, borderWidth: 0 },
{ label: 'Fastest', data: fastest, pointRadius: 0, borderWidth: 0, fill: '-1' },
{ label: 'Typical', data: median, fill: false }

New subscriptions, month to date

A running total, so it only climbs. The faint line is last month.

Cumulative
  • This month
  • Last month
Show config
let sum = 0;
const runningTotal = daily.map((v) => (sum += v));

SMS credit balance

Falls with each send, jumps on a top-up.

Stepped
Show config
{ stepped: 'before', fill: 'start', pointRadius: 0 }

Visitors through the day

A curved edge for a total that moves gently.

Smoothed
Show config
{ tension: 0.45, cubicInterpolationMode: 'monotone', fill: 'start' }

Orders packed against capacity

The team can pack 120 a day; the pale gap is capacity left over.

Against a limit
  • Orders packed
  • Spare capacity
  • Daily capacity
Show config
{ label: 'Packed', data: packed, fill: 'origin' },
{ label: 'Capacity', data: packed.map(() => 120), borderDash: [6, 5],
  fill: { target: 0, above: tint(gray, .1) } }

Store sessions around the autumn sale

The sale week is shaded, so its lift reads against the weeks around it.

Highlighted period
Show config
plugins: [{
  id: 'saleWeek',
  beforeDatasetsDraw({ ctx, chartArea: a, scales: { x } }) {
    const from = x.getPixelForValue(14) - step / 2, to = x.getPixelForValue(20) + step / 2;
    ctx.fillRect(from, a.top, to - from, a.height);
  },
}]

Phone and desktop visits

Two see-through fills, overlaid, not stacked.

Overlapping
  • Phone
  • Desktop
Show config
{ fill: 'origin', backgroundColor: fadeDown(series2) },
{ fill: 'origin', backgroundColor: fadeDown(series4) }
// No stacked: true, so both start from zero.

Revenue by month

One series, filled down to zero.

Basic
Show config
new Chart(canvas, {
  type: 'line',
  data: { labels, datasets: [{ label: 'Revenue', data, fill: 'origin' }] },
});

Revenue, this year and last

This year filled, last year dashed, so now and before read apart.

Year over year
  • This year
  • Last year
Show config
{ label: 'This year', data: thisYear, fill: 'origin' },
{ label: 'Last year', data: lastYear, fill: false, borderDash: [5, 5] }