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.jsonRegions by revenue
BumpChartBumpTabledefaultBumpChartLabels- +1 more
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
import { BumpChart } from "@/components/sheenui/charts/bump-chart";
import { bumpLegend } from "@/components/sheenui/charts/bump-chart/model";
import { BumpTable } from "@/components/sheenui/charts/bump-chart/table";
import { ChartCard } from "@/components/sheenui/charts/chart-parts/chart-card";
// Package build (after the first npm release, or a packed tarball): import { BumpChart, BumpTable, bumpLegend, ChartCard } from "@sheenui/theme";
const regions = [
{ key: "north", label: "North" },
{ key: "south", label: "South" },
{ key: "east", label: "East" },
];
const quarters = [
{ quarter: "Q1", north: 412, south: 388, east: 301 },
{ quarter: "Q2", north: 398, south: 421, east: 335 },
{ quarter: "Q3", north: 405, south: 447, east: 392 },
{ quarter: "Q4", north: 436, south: 430, east: 441 },
];
export function Example() {
return (
<ChartCard
title="Regions by revenue"
legend={bumpLegend(regions)}
table={<BumpTable data={quarters} index="quarter" series={regions} caption="Revenue rank by quarter" />}
>
<BumpChart data={quarters} index="quarter" series={regions} highlight="east" aria-label="Regions ranked by revenue, by quarter" />
</ChartCard>
);
}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
- Phone
- Social
import { BumpChart } from "@/components/sheenui/charts/bump-chart";
import { bumpLegend } from "@/components/sheenui/charts/bump-chart/model";
import { BumpTable } from "@/components/sheenui/charts/bump-chart/table";
import { ChartCard } from "@/components/sheenui/charts/chart-parts/chart-card";
// Package build (after the first npm release, or a packed tarball): import { BumpChart, BumpTable, bumpLegend, ChartCard } from "@sheenui/theme";
const channels = [
{ key: "chat", label: "Chat" },
{ key: "email", label: "Email" },
{ key: "phone", label: "Phone" },
{ key: "social", label: "Social" },
];
const responseTimes = [
{ month: "Jan", chat: 4, email: 190, phone: 22, social: 95 },
{ month: "Mar", chat: 7, email: 120, phone: 21, social: 61 },
{ month: "Jun", chat: 17, email: 33, phone: 23, social: 12 },
];
export function Example() {
return (
<ChartCard
title="Response time by channel"
legend={bumpLegend(channels)}
table={<BumpTable data={responseTimes} index="month" series={channels} higherIsBetter={false} caption="Response time rank" />}
>
<BumpChart
data={responseTimes}
index="month"
series={channels}
higherIsBetter={false}
patterns
format={(n) => n + " min"}
aria-label="Support channels ranked by response time"
/>
</ChartCard>
);
}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.tsxcomponents/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.tslib/{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
BumpChartLabels keys and English defaults (9)
BumpTable props
Keyboard
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
Related pages
48 charts pages in all: browse them on Charts.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .