Skip to content

Bump Chart for React

A React bump chart that shows how a ranking changes over time, one line per series with the rank in every dot. Pass data as readonly ChartRow[]: one row per point in time with a number per series, plus index and series.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/bump-chart.json

Regions by revenue

Use the left and right arrow keys to move through time and the up and down keys to move between ranks.

Rank by revenue

Revenue per region and quarter, ranked in each quarter. The lines draw in as the chart scrolls into view; hover a dot and the other lines step back. Pick a region to keep it in colour.

Regions by revenue

Rank in each quarter, 1 is the highest revenue

  • North
  • South
  • East
  • West
  • Central

Lower is better, with dash patterns

higherIsBetter={false} ranks the smallest number first, here the median response time per channel. patterns gives each line its own dash style, so the lines differ without colour; it turns on by itself from four series.

Response time by channel

Rank 1 is the fastest

  • Chat
  • Email
  • Phone
  • Social

Files to copy

13 folders · 29 files · 4 packages
From theme/src/
  • components/charts/{bump-chart.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-pointer.tsx, chart-tip.tsx, chart-utils.ts, heatmap.tsx}
  • components/charts/bump-chart/
  • components/charts/chart-parts/
  • components/charts/heatmap/
  • components/drawer/parts/sheet.tsx
  • components/kbd/
  • components/menu/
  • components/skeleton/
  • components/status-icons/
  • hooks/{use-controllable.ts, use-direction.ts, use-intersection.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}
  • motion/tokens.ts
  • lib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/bump-chart.jsonRegistry item: bump-chart. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".

Props

PropTypeDefaultDescription
data (required)readonly ChartRow[]NoneOne row per point in time: the index key plus one number per series key, e.g. { year: "2022", ada: 82, bo: 77 }.
index (required)stringNoneThe key of each row that names the point in time (the x axis).
series (required)readonly ChartSeries[]NoneThe competing series: { key, label, color? }. Ranks are computed per row across them.
rankBy"value" | "rank""value"What the numbers are: "value" ranks them in each row, "rank" treats them as ready-made ranks (1 = best).
higherIsBetterbooleantrueWith rankBy="value": whether a larger value ranks higher. Set false for times or error rates.
highlightstringNoneEmphasise one series (by key); the others step back. Hovering or reading a series does this too.
showLabelsbooleantruePrint the series names at the end of the lines.
patternsbooleantrue when series.length > 3Tell series apart without colour (dash styles).
heightnumbermax(220, ranks × row height + padding)Sets the height of the plot in px. It grows with the number of ranks (at least 220).
format((n: number) => string)formatCompact in localeFormats a value for the tooltip and table: takes the number, returns the text shown.
localestring"en"Locale of the default number format.
emptyStateReactNodeNoneShown when there is nothing to plot.
labelsPartial<BumpChartLabels>defaultBumpChartLabelsEvery other string, for translation: labels={{ roleDescription: "…" }}; omitted keys keep the English of defaultBumpChartLabels. All 9 keys of BumpChartLabels are listed in the key table under the props table.
aria-label (required)stringNoneNames the chart for assistive tech (required).
classNamestringNoneAdds extra classes to the outer element.
BumpChartLabels keys and English defaults (9)
Pass any key in labels; the rest keep the defaults of defaultBumpChartLabels.
KeyEnglish default
roleDescriptionbump chart
instructionsUse the left and right arrow keys to move through time and the up and down keys to move between ranks.
rank(rank, of) => `Rank ${rank} of ${of}`
valueValue
movedUp(places) => `Up ${places}`
movedDown(places) => `Down ${places}`
unchangedNo change
periodPeriod
noDataNo data

BumpTable props

PropTypeDefaultDescription
data (required)readonly ChartRow[]NoneOne row per point in time: the index key plus one number per series key, e.g. { year: "2022", ada: 82, bo: 77 }.
format((n: number) => string)formatCompact in localeFormats a value for the tooltip and table: takes the number, returns the text shown.
labelsPartial<BumpChartLabels>defaultBumpChartLabelsEvery other string, for translation: labels={{ roleDescription: "…" }}; omitted keys keep the English of defaultBumpChartLabels. All 9 keys of BumpChartLabels are listed in the key table under the props table.
localestring"en"Locale of the default number format.
index (required)stringNoneThe key of each row that names the point in time (the x axis).
series (required)readonly ChartSeries[]NoneThe competing series: { key, label, color? }. Ranks are computed per row across them.
rankBy"value" | "rank""value"What the numbers are: "value" ranks them in each row, "rank" treats them as ready-made ranks (1 = best).
higherIsBetterbooleantrueWith rankBy="value": whether a larger value ranks higher. Set false for times or error rates.
captionstringNoneHidden caption that names the table for screen readers.
classNamestringNoneAdds extra classes to the outer element.

Keyboard

KeysAction
TabFocus the chart. It is one tab stop; the arrow keys then read it.
←/→Move to the previous / next point in time (flipped in right-to-left text).
↑/↓Move to the series ranked one place higher / lower at that point.
Home/EndJump to the first / last point in time.
EscapeClear the reading.

Accessibility

  • The chart is a focusable figure named by its aria-label (the chart title), with the keyboard hint as its description and, inside a ChartCard with a table view, aria-details pointing at that table. Moving through it announces the series, the period, its rank and how far it moved, politely, once.
  • The rank is written in each dot and the series name at the end of its line, and from four series on every line gets its own dash style (patterns), so colour never identifies a series.
  • BumpTable is the table view: one row per period, one column per series, each cell its rank and value.
  • Reduced motion: the lines and dots appear at once and data changes jump instead of gliding.

All exports on this page

  • BumpChart — A bump chart: how the ranking of several series changes over time.
  • BumpTable — Every point in time with each series' rank (and its value), one column per series.
  • defaultBumpChartLabels — The built-in English strings of BumpChart; spread it into your own labels and change what you need.

When to use the bump chart

  • Use it for league tables and leaderboards over time, such as sales regions ranked by revenue each quarter, where who is ahead matters more than by how much.
  • Use it for top-N lists that reshuffle: search rankings, product popularity, support channels by response time. Set higherIsBetter to false when a smaller number ranks higher.
  • Pass ready-made ranks with rankBy="rank" when your data already holds positions, and highlight one series to tell the story of a single climber or faller.
  • Skip it when the size of the values matters, where a Line chart shows the gap between series, or with more than about ten series, where the lines cross too often to follow.
  • Pair it with ChartCard, bumpLegend and BumpTable for the legend, the Chart / Table tabs and a text version of every rank.

Frequently asked questions

48 charts pages in all: browse them on Charts.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .