Slope chart

A React component in Beamline's Charts & data-vis category.

Change between two points in time per item, by value or by rank: labels on both sides that never collide, rising and falling told by the end marker (▲ ▼) and the signed change as well as colour, and hover or focus to pick one item out.

Use it for

  • Before/after for a handful of items: share by channel this quarter against last, a ranking that moved.

Not for

Anatomy

  • title, description, table button
  • period headings (start, end; overline role)
  • start axis and end axis
  • one line per item, ending in ▲ (rose), ▼ (fell) or ● (flat)
  • start labels (item buttons: name and value; columns measured in the faces the look sets, so names never truncate while there is room)
  • end labels (value, signed change, name)
  • hatched stub for a missing end

Variants

  • 0: scale: value · rank (1 at the top)
  • 1: better: higher (rises are good, green) · lower (falls are good) · neither (accent and muted)
  • 2: labels by room: full (name and value on both sides) · medium (names on the start side) · narrow, on phones (values at the start; value, ▲▼ and name at the end)

States

  • loading (skeleton)
  • empty
  • missing start or end: the known point stays, a hatched stub and “Not measured” stand on the missing side, no line is invented
  • active item (its line thickens and is drawn again on top; the others fade toward the card colour, and their labels step down to ink-3, never below 4.5:1)
  • pinned item (aria-pressed)
  • table view (start, end, change)
  • right-to-left: categorical period columns mirror with the comparison table; figures and date ranges remain LTR-isolated
  • names keep their own direction (dir=auto), so a truncated name shows its start in RTL too

Keyboard

  • Tab focuses the active (or first) item; ↑/↓ move through items in their start order, Home/End to the ends
  • Focus or hover highlights the item; Escape releases it
  • Each item's accessible name reads both values and the change
  • Label buttons and pointer line targets are at least 24 px tall/wide. Stable item keys control pinning; hover/focus preview never changes the caller selection. Overlapping line targets resolve to the nearest drawn line, not SVG paint order.

Motion

Lines draw from the start axis once; new values or the other scale (value, rank) carry every line and label to its new height over the chart duration, while a resize places them at once. Highlight is immediate. Nothing moves under reduced motion.

Props

PropTypeDefaultDescription
dataSlopeItem[]—Measured start and end values for each comparison item. Required.
startLabel / endLabel (required)string—startLabel: Period headings: "Q2", "Q3". endLabel: Label for the last comparison point. Required.
scale"value" | "rank"—value: plot the values. rank: plot each period's ranking, 1 at the top.
better"higher" | "lower" | "neither"—Which direction reads as good: rises green when higher, falls green when lower; neither keeps colour neutral.
format / formatChange(v: number) => string—format: Formats a raw numeric value for display. Defaults to locale-aware number formatting. formatChange: The signed change; by default the difference in format's terms ("+5.1%"), or places in rank mode.
heightnumber | "fill"—Plot height in px (30 px per item, at least 200, by default), or "fill" for whatever height its container gives it.
active / defaultActive / onActiveChangestring | null—active: The highlighted item; hover and focus preview others. defaultActive: Initial active item when uncontrolled. Defaults to null. onActiveChange: Reports active item after a change; no callback by default.
title / hideTitle / descriptionstring / boolean / ReactNode—title: Heading shown above the content. Required. hideTitle: Hides the title; defaults to false. Deprecated: Use showTitle={false} instead. description: Supporting text beneath the label or heading. Defaults to no supporting text.
tableboolean—Offers a table view of the same chart data. Defaults to true.
loadingboolean—Shows the loading state while data or an operation is pending. Defaults to false.
actionsReactNode—Actions displayed with the heading or toolbar. Defaults to no actions.
classNamestring—Classes on the documented visual root; no override by default.
formatChangeSpoken(change: number) => string—Spoken amount/unit after rose or fell. Receives the signed change; return e.g. "18 percentage points".
classNamesChartClassNames—Classes for the named visual parts; no overrides by default.
style / refCSSProperties / Ref<HTMLElement>—style: Inline styles on the documented visual root; no overrides by default. ref: Receives the documented native target or imperative handle; omitted by default.
emptyLabelstring—What an empty chart says, in the product's own words ("No deploys yet"). Default: "No data for this range" on a chart over time, "No data yet" on the others.
showTitlebooleantrueShows the title visually while keeping its accessible name; defaults to true. Takes precedence over hideTitle.
title (required)string—Heading shown above the content. Required.
hideTitleboolean—Hides the title; defaults to false. Deprecated: Use showTitle={false} instead.
descriptionReactNode—Supporting text beneath the label or heading. Defaults to no supporting text.
startLabel (required)string—Period headings: "Q2", "Q3".
endLabel (required)string—Label for the last comparison point. Required.
format((value: number) => string)—Formats a raw numeric value for display. Defaults to locale-aware number formatting.
formatChange((change: number) => string)—The signed change; by default the difference in format's terms ("+5.1%"), or places in rank mode.
activestring | null—The highlighted item; hover and focus preview others.
defaultActivestring | null—Initial active item when uncontrolled. Defaults to null.
onActiveChange((key: string | null) => void)—Reports active item after a change; no callback by default.
styleCSSProperties—Inline styles on the documented visual root; no overrides by default.
refRef<HTMLElement>—Receives the documented native target or imperative handle; omitted by default.

Built from

Dependencies

motion

Import

import { SlopeChart } from "@beamline/slope-chart";

Get it

Slope chart is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Get Beamline · Connect your agent

More in Charts & data-vis

  • Sankey chart: Flows between stages as bands whose width is the amount: sources to pages to outcomes, budgets to teams; hovering or focusing a node lights its flows and…
  • Geo map: Values by country as a choropleth on the system's own world outline (no map service): classes from a sequential or diverging ramp with a legend you can…
  • Streamgraph: Stacked flows over time around a centre baseline, with silhouette, wiggle, expand (shares) and zero offsets: a legend that turns layers on and off, a…
  • Ridgeline: Distributions per group as overlapping density ridges (response time by region, order size by plan): an overlap control, median and p95 readouts per row…
  • Treemap: Nested rectangles sized by value (spend by team, then service), squarified so tiles stay close to square: labels that fit or hide, hover and focus…
  • Gantt chart: A plan as bars on a timeline: tasks grouped down the side, each bar from its start to its end with its progress, milestones as diamonds, arrows from each…
  • Activity heatmap: A calendar of daily counts, one cell per day on a sequential ramp: weeks across, weekdays down, month and weekday labels, a legend scale, hatched days…
  • Gauge: One value against a known range: a semicircle, a 270° dial or a full ring, filled or with a needle, coloured bands with their names (healthy, busy…
  • Radial chart: Progress of a few measures toward their targets as concentric rings, full or half circle, with a centre readout and a list of each ring's value, target…
  • Radar chart: A few series compared across the same five to eight dimensions as polygons on a polygon or circle grid; hover or arrow keys pick a dimension and read…
  • Scatter chart: Two measures of many items against each other, one point per item, or a bubble chart when a third measure sizes the points: groups by colour and shape…
  • Area chart: Amounts over time as filled areas: overlapping, stacked or as shares of 100%, five fills, two strokes, five curves, a range handle; gaps for missing…
  • Composed chart: Different measures on one time axis: bars, lines and areas per series, a left and a right value axis with their own formats, and reference lines.
  • Funnel chart: People or deals moving through ordered steps, each step a bar narrowing from the first: the part lost between two steps stays beside the next as a fading…
  • Waffle chart: Units of a whole as a grid of cells by category (seats used of a plan, tickets by channel): a 10×10 grid by default, hatched cells for units whose…
  • Line chart: Values over time as lines: curves, point markers, dashed series for forecasts, reference lines for limits and targets, an optional zero baseline and a…
  • Bar chart: Amounts by category as bars: columns or rows, grouped, stacked or as shares, reference lines, five looks (rounded, cells, trace, isometric, monospace), a…
  • Pie chart: A few shares of a whole as a pie or donut, with spaced slices, percent labels, a centre readout and a list of every slice with value and share; hovering…
  • Sparkline: A compact trend beside its value: point along it or focus it and use ← → to read each point; nulls are gaps. TrendLine is the bare line.

Part of Beamline UI: polished, editable React components and complete screens for custom applications. Build your own style from any look; tokens, fonts, radii, motion; not only colours.