Slope Chart
Slope chart for change between columns: slope, rank shift, bump chart, dumbbell and parallel coordinates.
Playground
Installation
Slope Chart comes with WunderUI Core and Pro, in the package from your plan. See the plans.
The charts live in their own entry point: import the chart, its card and its hooks from @wunderui/react/charts, not from @wunderui/react.
Then import what you need:
import {
SlopeChart,
SlopeChartProps,
SlopeChartVariant,
} from "@wunderui/react/charts"Then use it:
import { SlopeChart } from "@wunderui/react/charts"
const data = [
{ name: "Onboarding", y2025: 42, y2026: 58 },
{ name: "Dashboards", y2025: 51, y2026: 49 },
{ name: "Exports", y2025: 38, y2026: 47 },
]
export function NpsByArea() {
return (
<SlopeChart
data={data}
index="name"
series={[
{ key: "y2025", label: "2025" },
{ key: "y2026", label: "2026" },
]}
label="NPS by product area"
/>
)
}Expected result: You see three lines running from a 2025 column to a 2026 column, with the item names and values at both ends.
When to use
Use Slope Chart for
- Change between two moments for many items: before and after
- Rankings that move between periods (rank shift, bump chart)
- A dumbbell per row, or parallel coordinates over several measures
Use something else for
- Line Chart for a trend over many ordered points
- Bar Chart for values without change
- Radar Chart for one profile across measures
- Range Bar Chart for a span from a minimum to a maximum
States
Loading, empty and error keep the chart's size, so the card never jumps. Add a retry handler and the error state offers a Try again button.
Keyboard interactions
The plot is focusable, and arrow keys step through the items. The live region reads each from start to end with period names, like Atlas: 10 (Q1) to 15 (Q4), and rank variants add the rank.
- TaborShiftTab
- Moves focus to the plot and away from it. The plot is one tab stop; so is every legend badge.
- ArrowRightorArrowLeft
- Moves to the next or previous item. The tooltip follows, and a live region announces the one you are on. The first press starts at the first one (Left: the last one).
- HomeorEnd
- Jumps to the first or last item.
- Escape
- Clears the active point.
- EnterorSpace
- On a legend badge of a ChartCard: switches its series off or on. The last visible series stays on.
Behavior and motion
What the chart does on its own and what the page decides.
- Rows and columns
- Each row of data is an item and the series list the columns: two periods for slope, rank shift and dumbbell, many for the bump chart, or axes for parallel coordinates.
- Ranks
- Rank variants convert values to ranks per column and join them with smooth curves. The rank order decides whether the highest value is rank 1.
- Hover
- Hovering an item lifts its line and dims the rest. The tooltip names the item with its value in every column and, on rank variants, its rank.
- Loading, empty and error
- The chart keeps its size while loading, empty or failed, so the card never jumps. Add a retry handler to show a Try again button on error.
- Legend
- A ChartCard shows the series as badges. With two or more series each badge switches its series off, but the last visible one stays on.
- Size
- The chart fills the width of its container, and you set the plot height. Text never scales, so labels keep their size at every width.
Motion
The enter sequence and the hover follow the library's motion tokens.
- Draw-in
- Each line is drawn along its path when the chart first comes into view, after loading and when the data changes. You can turn it off.
- Reduced motion
- With reduced motion the chart appears at once. The tooltip, the crosshair and every state still work.
Anatomy
A slope chart compares change between columns: before and after, rank shift, bump over many periods, a dumbbell per row, or parallel coordinates. Hovering an item lifts its line and dims the rest.
NPS by area
| name | 2025 | 2026 |
|---|---|---|
| Onboarding | 42 | 58 |
| Dashboards | 51 | 49 |
| Exports | 38 | 47 |
| Billing | 29 | 41 |
| Support | 55 | 61 |
| Mobile | 33 | 44 |
Takes one row per item with an index field naming it, and the series as columns: two periods, many periods (bump) or axes. You choose whether the highest value is rank 1 and give one colour per row.
- data-slot="chart-plot"
The focusable region. Arrow keys walk its marks and a live region reads each one the way the tooltip shows it.
- data-slot="chart-marks"
A line (or dumbbell) per item, drawn along its path with the name and value at each end. Rank variants turn values into ranks per column and join them with smooth curves.
The series labels above the columns, or beneath a dumbbell's value axis.
- data-slot="chart-tooltip"
The item name with its value in every column and, on rank variants, its rank.
- data-slot="chart-message"
Muted bars under the shimmer, then the empty message when the data has no rows.
A hidden table with the items as rows and the columns as series.
Best practices
- Do
Keep to about ten items. Names are printed at both ends and more than ten overlap.
- Do
Highlight one or two items with colour and keep the rest neutral. A slope chart with ten bright lines has no focus.
- Do
Set the rank order to ascending when the values are already ranks, where 1 is the best.
- Don’t
Don't use it for items with very different magnitudes, because the steepest line is the largest value, not the biggest change. Use a rank shift or index the values to 100.
- Don’t
Don't use parallel coordinates for fewer than three axes. A slope chart does the same with less to learn.
API reference
One table for SlopeChart, listing every prop. The ChartCard around it has its own props, and the chart also works without one.
Takes one row per item with an index field naming it, and the series as columns: two periods, many periods (bump) or axes. You choose whether the highest value is rank 1 and give one colour per row.
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("slope-chart")The full library index for assistants is at /llms.txt.