Slope chart

Use it to compare the same items at two points: this week against last, or the first month against the latest. The slope of each line is the change, steep for big movers and flat for steady ones, and labels at both ends carry the numbers. Use it for a handful of items rather than dozens.

← All charts

Live demo

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

Tab into the chart once, then use the arrow keys (or Home and End) to move from item to item; Esc closes the tooltip. On a phone, touch an item.

How to use it

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

JavaScript
const chart = slope({
  items: [
    { label: 'Certificates', from: 6,  to: 15 },
    { label: 'Renewals',     from: 21, to: 25 },
    { label: 'Complaints',   from: 11, to: 4 }
  ],
  fromLabel: 'Week before',
  toLabel: 'Last week',
  fmt: v => Math.round(v),
  label: 'Conversations by theme, week on week'
});
document.querySelector('#host').append(chart);

Options

What you can pass to this chart.

items

[{ label, from, to, colour? }]. Colour follows direction unless you set one.

fromLabel, toLabel

Headings over the two axes.

fmt

Value formatter for the labels and tooltip.

upColour, downColour

Line colours for a rise and a fall (default orange and blue).

height

Chart height; by default it grows with the number of items.

label / empty

aria-label for screen readers; text shown when there is nothing to compare.

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.