Skip to content
OpenChart

Ranking and change

Slope, bump and range charts for who moved and by how much, as copyable recipes.

Recipes for the FT Visual Vocabulary “ranking” family: slope charts, bump charts, and range (dumbbell/arrow) charts. All three answer the same editorial question, “who moved, and by how much?”, with different emphasis.

Slope and bump are not separate chart types. They are mark: "line" plus a handful of public spec fields, documented here as copy-paste recipes. Range is its own mark (mark: "range").

All specs work with any framework. Swap the import to match yours:

// React
import { Chart } from "@opendata-ai/openchart-react";
<Chart spec={spec} />

// Vue
import { Chart } from "@opendata-ai/openchart-vue";
<Chart :spec="spec" />

// Svelte
import { Chart } from "@opendata-ai/openchart-svelte";
<Chart {spec} />

// Vanilla JS
import { createChart } from "@opendata-ai/openchart-vanilla";
createChart(container, spec);

Slope

Two points in time, one line per series. The strongest form for “before vs after”: every crossing line is a rank change, every steep line is a big move. Values live on the labels, so the y axis and gridlines go away entirely.

20102024Coal 15.0Natural gas43.2Nuclear 18.2Wind 10.3Hydro 5.6Solar 6.9Coal 44.8Natural gas23.9Nuclear 19.6Wind 2.3Hydro 6.3Solar 0.1Natural gas passed coal as the largest USelectricity source between 2010 and 2024Share of US electricity generation by source, %, 2010 vs 202420102024Coal 15.0Natural gas43.2Nuclear 18.2Wind 10.3Hydro 5.6Solar 6.9Coal 44.8Natural gas23.9Nuclear 19.6Wind 2.3Hydro 6.3Solar 0.1Natural gas passed coal as the largest USelectricity source between 2010 and 2024Share of US electricity generation by source, %, 2010 vs 2024
US electricity generation by source. Source: US Energy Information Administration, Electric Power Monthly.
{
  "mark": "line",
  "data": [
    {
      "year": "2010",
      "source": "Coal",
      "share": 44.8
    },
    {
      "year": "2024",
      "source": "Coal",
      "share": 15
    },
    {
      "year": "2010",
      "source": "Natural gas",
      "share": 23.9
    },
    {
      "year": "2024",
      "source": "Natural gas",
      "share": 43.2
    },
    {
      "year": "2010",
      "source": "Nuclear",
      "share": 19.6
    },
    {
      "year": "2024",
      "source": "Nuclear",
      "share": 18.2
    },
    {
      "year": "2010",
      "source": "Wind",
      "share": 2.3
    },
    {
      "year": "2024",
      "source": "Wind",
      "share": 10.3
    },
    {
      "year": "2010",
      "source": "Hydro",
      "share": 6.3
    },
    {
      "year": "2024",
      "source": "Hydro",
      "share": 5.6
    },
    {
      "year": "2010",
      "source": "Solar",
      "share": 0.1
    },
    {
      "year": "2024",
      "source": "Solar",
      "share": 6.9
    }
  ],
  "encoding": {
    "x": {
      "field": "year",
      "type": "ordinal"
    },
    "y": {
      "field": "share",
      "type": "quantitative",
      "axis": false,
      "scale": {
        "zero": false
      }
    },
    "color": {
      "field": "source",
      "type": "nominal"
    }
  },
  "endpointLabels": {
    "ends": "both",
    "content": "label value",
    "format": ".1f"
  },
  "legend": {
    "show": false
  },
  "chrome": {
    "title": "Natural gas passed coal as the largest US electricity source between 2010 and 2024",
    "subtitle": "Share of US electricity generation by source, %, 2010 vs 2024"
  }
}
import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 12 rows, as in the Spec tab; Copy includes them */];

const spec: ChartSpec = {
  data,
  "mark": "line",
  "encoding": {
    "x": {
      "field": "year",
      "type": "ordinal"
    },
    "y": {
      "field": "share",
      "type": "quantitative",
      "axis": false,
      "scale": {
        "zero": false
      }
    },
    "color": {
      "field": "source",
      "type": "nominal"
    }
  },
  "endpointLabels": {
    "ends": "both",
    "content": "label value",
    "format": ".1f"
  },
  "legend": {
    "show": false
  },
  "chrome": {
    "title": "Natural gas passed coal as the largest US electricity source between 2010 and 2024",
    "subtitle": "Share of US electricity generation by source, %, 2010 vs 2024"
  }
};

export function Example() {
  return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 12 rows, as in the Spec tab; Copy includes them */];

const spec: ChartSpec = {
  data,
  "mark": "line",
  "encoding": {
    "x": {
      "field": "year",
      "type": "ordinal"
    },
    "y": {
      "field": "share",
      "type": "quantitative",
      "axis": false,
      "scale": {
        "zero": false
      }
    },
    "color": {
      "field": "source",
      "type": "nominal"
    }
  },
  "endpointLabels": {
    "ends": "both",
    "content": "label value",
    "format": ".1f"
  },
  "legend": {
    "show": false
  },
  "chrome": {
    "title": "Natural gas passed coal as the largest US electricity source between 2010 and 2024",
    "subtitle": "Share of US electricity generation by source, %, 2010 vs 2024"
  }
};
</script>

<template>
  <Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 12 rows, as in the Spec tab; Copy includes them */];

const spec: ChartSpec = {
  data,
  "mark": "line",
  "encoding": {
    "x": {
      "field": "year",
      "type": "ordinal"
    },
    "y": {
      "field": "share",
      "type": "quantitative",
      "axis": false,
      "scale": {
        "zero": false
      }
    },
    "color": {
      "field": "source",
      "type": "nominal"
    }
  },
  "endpointLabels": {
    "ends": "both",
    "content": "label value",
    "format": ".1f"
  },
  "legend": {
    "show": false
  },
  "chrome": {
    "title": "Natural gas passed coal as the largest US electricity source between 2010 and 2024",
    "subtitle": "Share of US electricity generation by source, %, 2010 vs 2024"
  }
};
</script>

<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 12 rows, as in the Spec tab; Copy includes them */];

const spec: ChartSpec = {
  data,
  "mark": "line",
  "encoding": {
    "x": {
      "field": "year",
      "type": "ordinal"
    },
    "y": {
      "field": "share",
      "type": "quantitative",
      "axis": false,
      "scale": {
        "zero": false
      }
    },
    "color": {
      "field": "source",
      "type": "nominal"
    }
  },
  "endpointLabels": {
    "ends": "both",
    "content": "label value",
    "format": ".1f"
  },
  "legend": {
    "show": false
  },
  "chrome": {
    "title": "Natural gas passed coal as the largest US electricity source between 2010 and 2024",
    "subtitle": "Share of US electricity generation by source, %, 2010 vs 2024"
  }
};

const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);

The rows are the source table’s 2010 and 2024 columns, reshaped to one row per source and year.

What each field does:

  • endpointLabels.ends: 'both' puts a label column at both edges (plain endpoint labels are trailing-edge only).
  • endpointLabels.content: 'label value' joins the series name and its formatted value on one line (“Coal 44.8”). The classic FT look, name plus value on the left and value alone on the right, is content: { leading: 'label value', trailing: 'value' }.
  • axis: false on y removes the axis and its gridlines. The labels carry the values, so an axis would be redundant ink.
  • scale: { zero: false } lets the two rails span the data range instead of anchoring at zero, which is what makes the slopes readable.
  • legend: { show: false } because the labels already identify every series.

Because the spec sets endpointLabels explicitly, the label columns survive the compact (under 400px) breakpoint, where auto endpoint labels would normally hand off to a legend. A slope without its labels is unreadable, so explicit opt-in wins.


Bump

Rank over time. The y axis is the finishing position, reversed so 1st sits at the top, with ordinal tick labels (“1st, 2nd, 3rd”). Point markers anchor each step; monotone interpolation keeps the lines readable through crossings. Ties are fine: two series with the same rank share the same row.

const spec = {
  mark: { type: 'line', interpolate: 'monotone', point: true },
  data: [
    { season: '2019', team: 'Mercedes', position: 1 },
    { season: '2020', team: 'Mercedes', position: 1 },
    { season: '2021', team: 'Mercedes', position: 1 },
    { season: '2022', team: 'Mercedes', position: 3 },
    { season: '2023', team: 'Mercedes', position: 2 },
    { season: '2024', team: 'Mercedes', position: 4 },
    { season: '2019', team: 'Red Bull', position: 3 },
    { season: '2020', team: 'Red Bull', position: 2 },
    { season: '2021', team: 'Red Bull', position: 2 },
    { season: '2022', team: 'Red Bull', position: 1 },
    { season: '2023', team: 'Red Bull', position: 1 },
    { season: '2024', team: 'Red Bull', position: 3 },
    { season: '2019', team: 'Ferrari', position: 2 },
    { season: '2020', team: 'Ferrari', position: 6 },
    { season: '2021', team: 'Ferrari', position: 3 },
    { season: '2022', team: 'Ferrari', position: 2 },
    { season: '2023', team: 'Ferrari', position: 3 },
    { season: '2024', team: 'Ferrari', position: 2 },
    { season: '2019', team: 'McLaren', position: 4 },
    { season: '2020', team: 'McLaren', position: 3 },
    { season: '2021', team: 'McLaren', position: 4 },
    { season: '2022', team: 'McLaren', position: 5 },
    { season: '2023', team: 'McLaren', position: 4 },
    { season: '2024', team: 'McLaren', position: 1 },
    { season: '2019', team: 'Alpine', position: 5 },
    { season: '2020', team: 'Alpine', position: 5 },
    { season: '2021', team: 'Alpine', position: 5 },
    { season: '2022', team: 'Alpine', position: 4 },
    { season: '2023', team: 'Alpine', position: 6 },
    { season: '2024', team: 'Alpine', position: 6 },
  ],
  encoding: {
    x: { field: 'season', type: 'ordinal' },
    y: {
      field: 'position',
      type: 'quantitative',
      scale: { reverse: true, zero: false },
      axis: { values: [1, 2, 3, 4, 5, 6], format: 'ordinal' },
    },
    color: { field: 'team', type: 'nominal' },
  },
  endpointLabels: {
    ends: 'both',
    content: 'label',
    showMarker: false,
  },
  legend: { show: false },
  chrome: {
    title: 'McLaren Went From Midfield to Champions',
    subtitle: 'Formula 1 constructors championship, final position by season',
    source: 'Source: FIA official standings',
  },
};

What each field does:

  • scale: { reverse: true } flips the y range so rank 1 renders at the top. zero: false keeps rank 0 off the axis.
  • axis: { values: [1, 2, 3, 4, 5, 6], format: 'ordinal' } pins one tick per rank and formats them as ordinals. format: 'ordinal' is an OpenChart extension to the d3-format strings; it works anywhere a format string does.
  • interpolate: 'monotone' curves the lines through rank changes without overshooting; point: true marks every step.
  • endpointLabels.content: 'label' puts the name alone at both ends (the rank is already on the axis). showMarker: false skips the open-circle end markers, which would double up with the step points.

If your data has raw scores instead of precomputed ranks, derive the rank with the window transform first:

transform: [
  {
    window: [{ op: 'rank', field: 'points', as: 'position' }],
    sort: [{ field: 'points', order: 'descending' }],
    groupby: ['season'],
  },
],

Live example: Bump


Range (dumbbell)

When the story is the size of the change per category rather than trajectories over time, use mark: "range": one row per category, a dot at the start and end values. Set mark: { type: 'range', style: 'arrow' } for an arrowhead at the end value, or style: 'bar' for a plain floating bar.

50607080Life expectancy at birth (years)NigeriaIndiaRussiaBrazilChinaUSASouth KoreaJapanIndia gained 9.3 years of life expectancybetween 2000 and 2023, the US 2.6Life expectancy at birth, 2000 (gray) vs. 2023 (accent), selected countries50607080Life expectancy at birth (years)NigeriaIndiaRussiaBrazilChinaUSASouth KoreaJapanIndia gained 9.3 years of life expectancybetween 2000 and 2023, the US 2.6Life expectancy at birth, 2000 (gray) vs. 2023 (accent), selected countries
Life expectancy, 2000 and 2023. Source: UN World Population Prospects 2024.
{
  "mark": "range",
  "data": [
    {
      "country": "Japan",
      "y2000": 81.1,
      "y2023": 84.7
    },
    {
      "country": "South Korea",
      "y2000": 76,
      "y2023": 84.3
    },
    {
      "country": "USA",
      "y2000": 76.7,
      "y2023": 79.3
    },
    {
      "country": "China",
      "y2000": 71.6,
      "y2023": 78.6
    },
    {
      "country": "Brazil",
      "y2000": 70.1,
      "y2023": 75.8
    },
    {
      "country": "Russia",
      "y2000": 65.5,
      "y2023": 73
    },
    {
      "country": "India",
      "y2000": 62.7,
      "y2023": 72
    },
    {
      "country": "Nigeria",
      "y2000": 46.5,
      "y2023": 54.6
    }
  ],
  "encoding": {
    "y": {
      "field": "country",
      "type": "nominal",
      "sort": {
        "field": "y2023",
        "order": "ascending"
      }
    },
    "x": {
      "field": "y2000",
      "type": "quantitative",
      "title": "2000",
      "axis": {
        "title": "Life expectancy at birth (years)"
      }
    },
    "x2": {
      "field": "y2023",
      "type": "quantitative",
      "title": "2023"
    }
  },
  "chrome": {
    "title": "India gained 9.3 years of life expectancy between 2000 and 2023, the US 2.6",
    "subtitle": "Life expectancy at birth, 2000 (gray) vs. 2023 (accent), selected countries"
  }
}
import { Chart } from "@opendata-ai/openchart-react";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 8 rows, as in the Spec tab; Copy includes them */];

const spec: ChartSpec = {
  data,
  "mark": "range",
  "encoding": {
    "y": {
      "field": "country",
      "type": "nominal",
      "sort": {
        "field": "y2023",
        "order": "ascending"
      }
    },
    "x": {
      "field": "y2000",
      "type": "quantitative",
      "title": "2000",
      "axis": {
        "title": "Life expectancy at birth (years)"
      }
    },
    "x2": {
      "field": "y2023",
      "type": "quantitative",
      "title": "2023"
    }
  },
  "chrome": {
    "title": "India gained 9.3 years of life expectancy between 2000 and 2023, the US 2.6",
    "subtitle": "Life expectancy at birth, 2000 (gray) vs. 2023 (accent), selected countries"
  }
};

export function Example() {
  return <Chart spec={spec} />;
}
<script setup lang="ts">
import { Chart } from "@opendata-ai/openchart-vue";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 8 rows, as in the Spec tab; Copy includes them */];

const spec: ChartSpec = {
  data,
  "mark": "range",
  "encoding": {
    "y": {
      "field": "country",
      "type": "nominal",
      "sort": {
        "field": "y2023",
        "order": "ascending"
      }
    },
    "x": {
      "field": "y2000",
      "type": "quantitative",
      "title": "2000",
      "axis": {
        "title": "Life expectancy at birth (years)"
      }
    },
    "x2": {
      "field": "y2023",
      "type": "quantitative",
      "title": "2023"
    }
  },
  "chrome": {
    "title": "India gained 9.3 years of life expectancy between 2000 and 2023, the US 2.6",
    "subtitle": "Life expectancy at birth, 2000 (gray) vs. 2023 (accent), selected countries"
  }
};
</script>

<template>
  <Chart :spec="spec" />
</template>
<script lang="ts">
import { Chart } from "@opendata-ai/openchart-svelte";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 8 rows, as in the Spec tab; Copy includes them */];

const spec: ChartSpec = {
  data,
  "mark": "range",
  "encoding": {
    "y": {
      "field": "country",
      "type": "nominal",
      "sort": {
        "field": "y2023",
        "order": "ascending"
      }
    },
    "x": {
      "field": "y2000",
      "type": "quantitative",
      "title": "2000",
      "axis": {
        "title": "Life expectancy at birth (years)"
      }
    },
    "x2": {
      "field": "y2023",
      "type": "quantitative",
      "title": "2023"
    }
  },
  "chrome": {
    "title": "India gained 9.3 years of life expectancy between 2000 and 2023, the US 2.6",
    "subtitle": "Life expectancy at birth, 2000 (gray) vs. 2023 (accent), selected countries"
  }
};
</script>

<Chart {spec} />
import { createChart } from "@opendata-ai/openchart-vanilla";
import type { ChartSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";

const data = [/* 8 rows, as in the Spec tab; Copy includes them */];

const spec: ChartSpec = {
  data,
  "mark": "range",
  "encoding": {
    "y": {
      "field": "country",
      "type": "nominal",
      "sort": {
        "field": "y2023",
        "order": "ascending"
      }
    },
    "x": {
      "field": "y2000",
      "type": "quantitative",
      "title": "2000",
      "axis": {
        "title": "Life expectancy at birth (years)"
      }
    },
    "x2": {
      "field": "y2023",
      "type": "quantitative",
      "title": "2023"
    }
  },
  "chrome": {
    "title": "India gained 9.3 years of life expectancy between 2000 and 2023, the US 2.6",
    "subtitle": "Life expectancy at birth, 2000 (gray) vs. 2023 (accent), selected countries"
  }
};

const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createChart(container, spec);

Live examples: Dumbbell | Arrow | Range bar


Picking within the family

You want to show Use
Before vs after for many series, values matter Slope
Rank trajectories across several periods Bump
Size of change per category, one period pair Range (dumbbell or arrow)
Continuous values over many periods Plain multi-series line

Grouped bar lists and uncertainty

Bar lists support encoding.group for section headers, sort: null to retain input order, an explicit encoding.value.scale.domain for comparisons, and x reference lines such as a lift baseline at 1. labels.format, prefix and suffix control the displayed row value. Bar and range marks separately support labels.content to compose names and values. For estimates with uncertainty, layer an errorbar with a point instead of encoding the interval as a filled bar. Supply all interval bounds upstream. See static rendering for server output.