Search documentation

Search pages, components, blocks, styles and colours.

Get started
Skip to content

Bump Chart

PreviousNext

Rank over time, as lines through each series' place at every index, so you see who overtook whom.

Top products
Acme Inc, rank by revenue each month
Product rank by revenue
AtlasPulseLedgerRelayBeacon
Jun#1#2#3#4#5
Jul#1#3#2#4#5
Aug#2#4#1#3#5
Sep#3#5#1#2#4
Oct#4#5#2#1#3
Nov#4#5#3#1#2

Give it a row per index, the field that names each index (index) and a config that names the series; each row holds every series' rank under its config key. Rank 1 sits at the top and the ranks below it are evenly spaced, so the chart shows places, not sizes. Each series is a line in the next colour of the chart palette, curving from place to place, with a ring at every point that holds its rank. When the plot has room, each series' name sits past its last point.

Point at a line to dim the others, or point at a series in the legend. Point at the chart, drag a finger across it or tab to it and use the arrow keys: a crosshair finds the index and a tooltip lists every series there, top rank first, with how far it moved since the index before (↑2, ↓1, or – for no change). The legend shows each series' latest rank and its last move, hides a series when pressed and spotlights it when pointed at.

Bump Chart is part of the Fabricator style. It's drawn in SVG, so the same component ships for every base, and its layout comes from the same model as the React Native version.

Installation

bunx --bun fabricator-ui@latest add bump-chart

Usage

import { BumpChart } from "@/components/ui/bump-chart"
import { type ChartConfig } from "@/components/ui/chart-kit"
const data = [
  { month: "Jun", atlas: 1, pulse: 2, ledger: 3 },
  { month: "Jul", atlas: 1, pulse: 3, ledger: 2 },
  { month: "Aug", atlas: 2, pulse: 3, ledger: 1 },
]
 
const config = {
  atlas: { label: "Atlas" },
  pulse: { label: "Pulse" },
  ledger: { label: "Ledger" },
} satisfies ChartConfig
 
<BumpChart data={data} index="month" config={config} label="Product rank by revenue" />

A missing rank breaks the series' line at that index. Ranks start at 1; the chart has as many places as the largest rank it shows, so ranks from a longer list (a league of twenty, five of them shown) keep their true places. The chart fills its container's width and is 18rem tall until you give it a height with className.

Examples

Ranking scores

ranking="score" takes each series' score instead and ranks the series at every index, highest first; equal scores keep the order of config. The tooltip then gives each score with its rank, and hiding a series ranks the rest among themselves. Shuffle deals new scores: every point moves to its new place.

Team rank by points each week
DesignPlatformGrowthMobileData
W142 pts (#1)38 pts (#2)31 pts (#3)27 pts (#4)19 pts (#5)
W236 pts (#2)44 pts (#1)29 pts (#4)33 pts (#3)24 pts (#5)
W331 pts (#3)47 pts (#1)35 pts (#2)30 pts (#4)28 pts (#5)
W434 pts (#4)41 pts (#1)39 pts (#2)26 pts (#5)37 pts (#3)
W529 pts (#5)36 pts (#3)45 pts (#1)31 pts (#4)40 pts (#2)
W633 pts (#4)35 pts (#3)48 pts (#1)28 pts (#5)43 pts (#2)

Colours

Series take the chart palette in the order of config, and keep their colour when another is hidden. Give a series its own with color: a palette slot, an upstream chart token (chart-1 … chart-5), a role (primary, info, success, …), a CSS variable (var(--brand)) or any CSS colour.

TokenHueTokenHue
--chart-series-1blue--chart-series-5magenta
--chart-series-2orange--chart-series-6green
--chart-series-3aqua--chart-series-7violet
--chart-series-4amber--chart-series-8red

Rings are filled with the card colour and stroked in the series' colour, and the rank inside stays in the text colour, so it reads in both modes. Names past the lines are in the text colour too, beside the ring that keys them.

Motion

  • Sweep: the first time the chart scrolls into view, the lines sweep in from the start edge on the reveal role, and each ring appears as the sweep passes it. Once per mount.
  • Morph: when the ranks change, through data, config, ranking or the visible series, every point moves to its new place on the move role. A series being shown rises in from below; one being hidden sinks away. Data with a different number of indices redraws instead.
  • Glide: the crosshair and the tooltip glide between indices on the glide role.

All three follow the motion speed of the region they sit in. Reduce Motion and the instant speed draw the chart at once and drop the glide; animate={false} does the same for one chart.

API Reference

BumpChart

All other props go to the root <div>.

PropTypeDefault
dataTDatum[]required
configChartConfigrequired
indexkeyof TDatumrequired
labelstringrequired: the accessible name
ranking"rank" | "score""rank"
formatValue(value: number, key: string) => string1,234, for scores
formatIndex(value: string, datum: TDatum) => stringthe field as text
legendbooleanon for two or more series
tooltipbooleantrue
animatebooleantrue
loadingbooleanfalse
emptyReactNode"No data"
onActiveChange(active: ChartActive<TDatum> | null) => void-

ChartConfig

FieldTypeDefault
labelstringrequired
colorChartColorthe next palette slot

Data attributes

AttributeElementPresent when
data-slot="bump-chart"rootalways
data-loadingrootloading is true
data-slot="chart-plot"the plotalways
data-slot="chart-series"a linealways; data-dimmed while another is pointed at or spotlit
data-slot="bump-chart-points"a series' ringsalways; data-dimmed as its line
data-slot="bump-chart-dot"a ringa series has a rank at that index
data-slot="bump-chart-name"a series' namethe plot has room for names
data-slot="chart-legend"the legendthe legend shows
data-slot="bump-chart-standing"a legend row's rankthe series is shown
data-slot="chart-tooltip"the tooltipan index is inspected

Accessibility

  • The plot is a slider named after label ("Product rank by revenue: inspect values"). Tab to it, then the arrow keys step through the indices, Home and End jump to the first and last, and Escape lets go. Its value text reads the tooltip: the index and every series with its rank and move.
  • Every rank is also in a table hidden from sight, so a screen reader can read the data without inspecting it.
  • With two or more series the legend always shows, so no series is told apart by colour alone. Its items are toggle buttons with aria-pressed, and each one's name includes the latest rank.
  • Moves are written as arrows with a number, never as colour.
  • loading sets aria-busy on the root and dims the last drawing until new data arrives.