Slope Chart
ProNewHow a set of measures moved between two moments, labelled at both ends with leaders where labels are moved apart, drawn one line after another.
Installation
pnpm dlx shadcn@latest add @viewport/slope-chart
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| title* | string | — |
| fromLabel* | stringThe names of the two columns, e.g. two versions or two dates. | — |
| toLabel* | string | — |
| items* | SlopeItem[] | — |
| format | (value: number) => string | (value) => `${value}%` |
| caption | React.ReactNodeA line under the chart. | — |
| height | numberThe height of the plot, in pixels. | 400 |
| className | string | — |
Accessibility
- Named as an image that states every measure's old and new value.
- Names stay on one side on narrow containers so the lines keep their room.
- Hover isolates one line; nothing depends on hover to be read.
- Lines appear already drawn under reduced motion.