Ridgeline
Stacked smoothed density curves comparing distributions across multiple groups.
import { RidgelineChart } from '@uthereal/ui/ridgeline-chart'Ridgeline chart playground
| Group | Count | Minimum | Lower quartile | Median | Upper quartile | Maximum |
|---|---|---|---|---|---|---|
| Jan | 30 | -1.3 | 1.625 | 3.1 | 5.1 | 6.9 |
| Mar | 30 | 4.2 | 7.55 | 10.25 | 12.8 | 15.4 |
| May | 30 | 14.1 | 17.15 | 19.05 | 20.8 | 24.2 |
| Jul | 30 | 23.7 | 25.1 | 27 | 28.85 | 31.5 |
| Sep | 30 | 15.3 | 18.575 | 20.7 | 22.975 | 26.9 |
| Nov | 30 | 3 | 6.3 | 8.1 | 10.475 | 12.5 |
Overview
A ridgeline chart compares the shape, spread, and center of multiple distributions simultaneously. Each group's raw numeric observations render as a Gaussian kernel density curve in stacked rows that can overlap. Every ridge marks its median and, when tint is enabled, shades by median from a light tint of the primary series color to full strength with a median key below the axis. Exploring a ridge lifts it above its neighbors, highlights its interquartile range (middle half), dims remaining ridges, and tracks a value cursor reporting the cumulative share at or below that value. A native data table exposes each group's count and five-number summary.
Use a ridgeline chart to compare distribution shapes across up to 24 groups, such as daily highs by month or response latency by region. To compare a single summary value per group, use a bar chart.
Usage
import { RidgelineChart } from '@uthereal/ui/ridgeline-chart'
export function Highs({
months,
}: {
months: { id: string; label: string; values: number[] }[]
}) {
return <RidgelineChart title="Daily highs by month" groups={months} />
}Pass raw observations rather than precomputed summaries; roughly ten or more observations per group yield a clear density curve. Pass active and onActiveChange to control which ridge is lifted.
Behavior
All ridges share one value axis and one density scale so peak heights compare directly across groups. When domain is omitted, the axis pads the observed range by 2.5 bandwidths on each side and rounds to clean steps (1, 2, or 5 times a power of ten) with subtle vertical gridlines. When bandwidth is omitted, smoothing uses Silverman's rule of thumb per group.
overlap (default 2.4, range 0.5–4) sets peak ridge height in row heights (rowHeight, default 30 px); at 1, ridges touch without overlapping. Lower rows cover rows behind them, and pointer hit-testing selects the frontmost ridge under the cursor. Set tint: false to disable median shading. Group labels sit in a 52 px gutter (36 px below 420 px plot width) and truncate with an ellipsis.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
title | stringDefault: "Ridgeline chart" | 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: "{label}: median {median}, middle half {q1} to {q3}, range {min} to {max}" | Announced when keyboard focus moves to a ridge. {label}, {median}, {q1}, {q3}, {min}, {max} and {count} 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). |
groups | RidgelineGroup[]Default: [{"id":"jan","label":"Jan","values":[1,3,2,4,0,5,3,2,6,4,3,1]},{"id":"apr","label":"Apr","values":[11,14,13,16,12,15,17,13,14,18,12,15]},{"id":"jul","label":"Jul","values":[24,27,26,29,25,28,30,26,27,31,25,28]},{"id":"oct","label":"Oct","values":[12,15,13,14,11,16,13,12,15,17,14,13]}] | One ridge per group, top to bottom, at most 24: an id, a label and the raw observations (1–2000 numbers). The ridge is their smoothed density. |
groupLabel | stringDefault: "Group" | Header of the group column in the data table. |
statLabels | RidgelineStatLabelsDefault: {"count":"Count","min":"Minimum","q1":"Lower quartile","median":"Median","q3":"Upper quartile","max":"Maximum","middleHalf":"Middle half","range":"Range","between":"{low} to {high}"} | Names of the statistics in the tooltip and the table: count, min, q1, median, q3 and max, plus middleHalf and range (tooltip rows) and between, the "{low} to {high}" template of a span. |
cursorLabel | stringDefault: "{share} at or below {value}" | The value cursor reading in the tooltip and announcement: {share} of the group at or below {value}. The cursor follows the pointer, or Left and Right on the keyboard. |
overlap | numberDefault: 2.4 | How tall the highest ridge rises, in row heights (0.5–4; 2.4 by default). Above 1, ridges reach into the rows above. |
rowHeight | integerDefault: 30 | Height of one row in pixels (20–80; 30 by default). |
domain | array— | A fixed value axis as [low, high]. Omit it to pad the data by 2.5 bandwidths on each side and round out to clean steps. |
bandwidth | number— | Smoothing of the density in value units. Omit it to use Silverman's rule for each group. |
defaultActive | string— | The id of the group whose ridge is lifted at first, with its tooltip, while the others dim. Pointer and keyboard focus then move it; the lifted ridge is host state. |
tint | booleanDefault: true | Shade each ridge by its median, from a light tint of the first series color (lowest) to its full strength (highest), with a median key under the axis; off draws every ridge in the first series color. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | RidgelineChartTheme— | Color mode, accent, and tokens, including the chart palette and sequential ramp. See Theming. |
motion | none | subtle | expressiveDefault: "subtle" | Draw-in and data change animation preset. System reduced-motion preferences take precedence. |
motionOptions | ChartMotionOptions— | draw (ridges rising from their baselines in a top-down wave when the chart scrolls into view) and morph (ridges moving to new data): a tween with a duration (ms) or a spring. Defaults are Arc ridgeline springs: a critically damped 1s spring for draw and a .7s spring with a .08 bounce for morph. |
dir | ltr | rtl— | Reading direction of the text. The value axis always runs left to right. Omit it to inherit the page direction. |
React integration
| Prop | Purpose |
|---|---|
active | Controlled lifted group ID, or null for none |
onActiveChange | Fires with the lifted group 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 and lift the first ridge |
ArrowUp, ArrowDown | Move to the previous or next ridge |
ArrowLeft, Right | Step the value cursor along the active ridge by one axis step |
Home, End | Jump to the first or last ridge |
Escape | Clear the lifted ridge and tooltip |
The chart renders a <figure> named by title and described by description. aria-details links to a native data table listing each group's count, minimum, lower quartile, median, upper quartile, and maximum (statLabels). The SVG drawing is hidden from assistive technology.
The plot forms a single tab stop. Each move lifts the active ridge, positions the 1 px ink crosshair and floating tooltip (median, middle half, range, and cumulative share), and announces politely using pointLabel and cursorLabel. In RTL, text follows the reading direction while the value axis runs left to right.
Motion and theming
When 30% of the chart enters the viewport, ridges rise from flat in a top-down wave on a single 1 s critically damped spring across 96 density samples; server-rendered markup is final. Data updates spring ridges, medians, and the value domain over 700 ms (bounce 0.08) while median tints transition over 480 ms. The lifted ridge rises 6 px and fades in over 160 ms while remaining ridges dim over 240 ms. The tooltip trails the pointer or keyboard cursor on a snappy spring and fades and scales in over 160 ms. motionOptions.draw and motionOptions.morph accept a tween with duration (ms) or a spring. motion="none" and prefers-reduced-motion: reduce disable springs and CSS transitions across ridges, gridlines, crosshair, tooltip, and labels.
theme accepts a mode, an accent, and semantic tokens including the chart palette (series1 drives median tinting) and borderSubtle for gridlines. An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, RidgelineChart is a leaf with no actions. The lifted ridge is host state stored at /components/instance-<id>/active, initialized from defaultActive. The host updates groups through composition updates. See Building with agents.
{
"type": "RidgelineChart",
"props": {
"title": "Response time by region",
"groups": [
{
"id": "eu",
"label": "Europe",
"values": [120, 140, 135, 160, 150, 128, 142]
},
{
"id": "us",
"label": "Americas",
"values": [180, 210, 195, 220, 205, 190, 200]
}
]
},
"children": []
}