Slope chart
Connects start and end values across two columns to compare directional change and rank shifts.
import { SlopeChart } from '@uthereal/ui/slope-chart'Slope chart playground
| Item | Q1 | Q2 | Change |
|---|---|---|---|
| 3.1% | 4.6% | +1.5% | |
| Organic search | 3.4% | 3.6% | +0.2% |
| Paid social | 1.9% | 1.3% | −0.6% |
Overview
A slope chart connects each item's start value and end value between two vertical axes, labeled with label and value on the start side and value plus rank change (an arrow and count, or =) on the end side. Slopes and crossings expose direction, magnitude, and rank order shifts immediately. Lines render in neutral ink by default, while highlight assigns one focal item the primary series color. Pointing or focusing brings one item forward at full ink, dims remaining items, and displays a tooltip with both values, change, and rank movement. A data table lists every item.
Use a slope chart for before-and-after comparisons across up to 24 items. For more than two time points, use a line chart. For single-point category comparisons, use a bar chart.
Usage
import { SlopeChart } from '@uthereal/ui/slope-chart'
export function Channels() {
return (
<SlopeChart
title="Conversion by channel"
startLabel="Q1"
endLabel="Q2"
highlight="email"
valueFormat={{ style: 'percent', minimumFractionDigits: 1 }}
items={[
{ id: 'email', label: 'Email', start: 0.031, end: 0.046 },
{ id: 'search', label: 'Organic search', start: 0.034, end: 0.036 },
{ id: 'social', label: 'Paid social', start: 0.019, end: 0.013 },
]}
/>
)
}Supply unique id values for each item. highlight and defaultActive must match an item id in items. Pass active and onActiveChange to control the focused item from the host.
Behavior
The value axis scales automatically to fit all start and end values, with hairline vertical axes on both columns. When height is omitted, plot height grows by 44 px per item (minimum 200 px) beneath a 28 px column header band. Overlapping end labels separate automatically and connect back to their dots with short leader lines.
Below 440 px container width, label typography steps down and columns move inward. Set ranks: false to hide rank-change indicators beside end values. Touch drags scrub items and clear on release. In RTL (dir="rtl"), the start column renders on the right.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
title | stringDefault: "Conversion by channel" | Figure title. It names the chart for assistive technology and captions the data table. |
description | string— | One or two sentences on what the chart shows, below the title; omit it when the title says enough. |
tableToggle | booleanDefault: false | Show a button that reveals the data table. The table is always available to assistive technology. |
tableLabel | stringDefault: "Data table" | Name of the data table button. |
pointLabel | stringDefault: "{item}, {startLabel} {start}, {endLabel} {end}, {change}, {rank}" | Announced when keyboard focus moves to an item. {item}, {startLabel}, {start}, {endLabel}, {end}, {change} (signed) and {rank} (the rank move text) are filled in. |
valueFormat | NumberFormat— | How values appear in the tooltip, table and axis: decimal, percent or currency, with fraction digits. Axis ticks are compacted (12.9K). |
locale | string— | BCP 47 locale for numbers and dates. Omit it to inherit the application locale (en-US by default). |
items | SlopeItem[]Default: [{"id":"email","label":"Email","start":3.1,"end":4.6},{"id":"search","label":"Organic search","start":3.4,"end":3.6},{"id":"social","label":"Paid social","start":1.9,"end":1.3}] | The items, each with an id, a label and a start and an end value. At most 24. |
startLabel | stringDefault: "Q1" | Heading of the start column, such as "2025". |
endLabel | stringDefault: "Q2" | Heading of the end column, such as "2026". |
highlight | string— | The id of the one item the story is about, drawn in the first series color (the accent hue). Every other line is neutral ink; omit it to draw them all in ink. |
defaultActive | string— | The id of the item in focus at first: it comes forward in ink with its tooltip while the others fade. Pointer and keyboard focus then move it; the item in focus is host state. |
ranks | booleanDefault: true | Show the rank move beside each end value: an arrow and the number of places, or "=" when the rank held. |
rankUpLabel | stringDefault: "up {count} to rank {rank}" | Rank move text in the tooltip and announcement when an item rose. {count} (places) and {rank} (its end rank) are filled in. |
rankDownLabel | stringDefault: "down {count} to rank {rank}" | Rank move text when an item fell. {count} and {rank} are filled in. |
rankSameLabel | stringDefault: "same rank" | Rank move text when an item kept its rank. |
categoryLabel | stringDefault: "Item" | Header of the item column in the data table. |
changeLabel | stringDefault: "Change" | Header of the change column in the data table. |
height | integer— | Plot height in pixels below the 28px column headings (120–1200). Omit it for 44px per item, at least 200. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | SlopeChartTheme— | Color mode, accent, and tokens, including the chart palette. See Theming. |
motion | none | subtle | expressiveDefault: "subtle" | Draw-in and data change animation preset. System reduced-motion preferences take precedence. |
motionOptions | ChartMotionOptions— | draw (when the chart scrolls into view, items 50ms apart: start dots pop, lines trace, end dots and labels follow) and morph (lines moving to new data): a tween with a duration (ms) or a spring. |
dir | ltr | rtl— | Reading direction. rtl puts the start column on the right. Omit it to inherit the page direction. |
React integration
| Prop | Purpose |
|---|---|
active | Controlled focused item ID, or null for none |
onActiveChange | Fires with the focused item ID (or null) as focus moves, in both modes |
preset | Application defaults, overridden by explicit instance props |
tokens | CSS variables applied after the typed theme |
ref | Ref forwarded to the root <figure> |
className, style | Applied to the root <figure> |
| Native attributes | id, data-*, and remaining <figure> attributes forwarded to the root |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Focus the plot on the top-ranked end item |
ArrowDown, Right | Move to the next item in end-rank order |
ArrowUp, Left | Move to the previous item in end-rank order |
Home, End | Jump to the first or last item in end-rank order |
Escape | Clear the focused item and tooltip |
The chart renders a <figure> named by title and described by description. aria-details links to a native data table with item, start, end, and change (changeLabel) columns. The SVG drawing is hidden from assistive technology.
The plot is a single tab stop walking items in end-rank order. Pointer and keyboard share one active focus state; blurring clears focus. Each move shows the tooltip and announces politely using pointLabel along with rankUpLabel, rankDownLabel, and rankSameLabel. Labels always render in readable ink rather than line color.
Motion and theming
When 30% of the chart enters the viewport, items draw in 50 ms apart: start dots pop in on a snappy spring, lines trace across over 700 ms, and end dots and labels follow; server-rendered markup is final. Hover and focus dim non-active items over 240 ms while the tooltip glides on its own spring and scales in over 160 ms. Data updates spring lines, dots, leaders, and labels to new positions by item ID on motionOptions.morph, rolling changed rank counts in the direction of movement. motionOptions.draw and motionOptions.morph accept a tween with duration (ms) or a spring. motion="none" and prefers-reduced-motion: reduce disable draw-in and morph transitions.
theme accepts a mode, an accent, and semantic tokens including the chart palette. An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, SlopeChart is a leaf with no actions. The focused item is host state stored at /components/instance-<id>/active, initialized from defaultActive. The host updates items through composition updates. See Building with agents.
{
"type": "SlopeChart",
"props": {
"title": "Satisfaction by team",
"startLabel": "Q1",
"endLabel": "Q2",
"items": [
{ "id": "support", "label": "Support", "start": 72, "end": 81 },
{ "id": "sales", "label": "Sales", "start": 68, "end": 64 }
]
},
"children": []
}