# Slope Chart

Slope chart for change between columns: slope, rank shift, bump chart, dumbbell and parallel coordinates.

- Category: Charts
- Page: https://wunderui.com/components/slope-chart
- Tier: Core and Pro

## Install

Slope Chart ships with WunderUI Core and Pro in the @wunderui/react package.

## Import

```tsx
import { SlopeChart, SlopeChartProps, SlopeChartVariant } from "@wunderui/react"
```

## Minimal usage

Then use it:

```tsx
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

- [Line Chart](https://wunderui.com/components/line-chart) for a trend over many ordered points
- [Bar Chart](https://wunderui.com/components/bar-chart) for values without change
- [Radar Chart](https://wunderui.com/components/radar-chart) for one profile across measures
- [Range Bar Chart](https://wunderui.com/components/range-bar-chart) for a span from a minimum to a maximum

## Keyboard

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.

| Key | Action |
|---|---|
| `Tab` or `Shift+Tab` | Moves focus to the plot and away from it. The plot is one tab stop; so is every legend badge. |
| `ArrowRight` or `ArrowLeft` | 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). |
| `Home` or `End` | Jumps to the first or last item. |
| `Escape` | Clears the active point. |
| `Enter` or `Space` | On a legend badge of a ChartCard: switches its series off or on. The last visible series stays on. |

## Behavior

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 keeps its line and dims the rest to --chart-dim. 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

- `SlopeChart`: 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.
- `Plot`: The focusable region. Arrow keys walk its marks and a live region reads each one the way the tooltip shows it.
- `Marks`: A line (or dumbbell) per item, drawn along its path; each point appears as the line reaches it and the end labels once it has arrived. The name and value sit at each end while the card has room; the plot keeps at least 40 % of the card, so on narrow cards the names move to one side, are shortened or give way to the tooltip. Rank variants turn values into ranks per column and join them with smooth curves.
- `Column headers`: The series labels above the columns, or beneath a dumbbell's value axis.
- `Tooltip`: The item name with its value in every column and, on rank variants, its rank.
- `Loading, empty and error`: Muted bars under the shimmer, then the empty message when the data has no rows.
- `Data table and live region`: A hidden table with the items as rows and the columns as series.

## Best practices

### When to use

- Use it for change between two points for several items, such as plan revenue this quarter against last. For many periods use LineChart, or the bump chart when ranks matter more than values.

### Do

- Keep to about ten items. Names are printed at both ends and more than ten overlap.
- Highlight one or two items with colour and keep the rest neutral. A slope chart with ten bright lines has no focus.
- 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 use parallel coordinates for fewer than three axes. A slope chart does the same with less to learn.

## API reference

### SlopeChart

| Prop | Type | Default | Description |
|---|---|---|---|
| data* | readonly ChartDatum[] |  | One row per item (team, product …). |
| index* | string |  | Field holding the item's name. |
| series* | readonly ChartSeries[] |  | The columns: two periods (slope, rank shift, dumbbell), many periods (bump) or the axes (parallel coordinates). |
| activeIndex | number \| null |  | The active point (hovered or focused) as an index into `data`, to control it yourself. `null` shows none. |
| animate | boolean |  |  |
| animationKey | string \| number |  |  |
| className | string |  | Extra classes for the root element of the chart. |
| colors | readonly ChartColor[] |  | Colours per row (slope, rank, bump, parallel). Default: palette order. |
| defaultActiveIndex | number \| null |  | The point that is active at first, for an uncontrolled chart. It shows the tooltip without a pointer. |
| description | string |  |  |
| height | number |  |  |
| hiddenSeries | readonly string[] |  | Row names (or, for the dumbbell, series keys) switched off in the legend. |
| label | string |  |  |
| onActiveIndexChange | (index: number \| null) => void |  | Called with the index when the pointer or the arrow keys move to another point, and with `null` when they leave. Use it to show the hovered value in a headline. |
| onRetry | () => void |  | Shows a Try again button in the error state and calls this when it is pressed. |
| rankOrder | "desc" \| "asc" | "desc" | Rank order of `rank-shift` and `bump-chart`: highest value = #1 (`desc`, default) or lowest (`asc`, e.g. when the values are ranks already). |
| state | "ready" \| "loading" \| "empty" \| "error" |  |  |
| valueFormatter | ChartValueFormatter |  |  |
| variant | "slope-chart" \| "rank-shift" \| "bump-chart" \| "dumbbell" \| "parallel-coordinates" | "slope-chart" | Figma variant. Default `slope-chart`. |
| width | number |  |  |

## Examples

### States

### Card width

## In context

### NPS by Area

Two years side by side with the biggest moves.

## For AI agents

`get_component("slope-chart")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
