Sparkline
A React component in Beamline's Charts & data-vis category.
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.
Use it for
- A trend next to a number in a card, a row or a header.
Not for
- Charts people read in detail (line-chart).
Anatomy
- label
- change
- value
- line with area
- scrub guide and dot
States
- rest
- scrubbing
- gaps
Keyboard
- Focus and ← → to read points
- Escape resets
Motion
New data reshapes the line and its area in place over --pui-duration-considered (a series of the same length interpolates; another length places at once). Pointing at it or focusing it reveals the highest point (filled) and the lowest (hollow); always shown on touch.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | (number | null)[] | — | Trend samples in time order; null marks an unmeasured sample. Required. |
label / value / change | string | — | label: What it measures: "Signups". value: The headline value (usually the latest). change: "+18%"; its colour follows tone. |
tone | "accent" | "current" | "success" | "danger" | "warning" | "neutral" | — | Semantic colour of the displayed content. Defaults to "accent". |
labels / formatValue | string[] / (v, i) => string | — | labels: A name per point ("Mon", "12 Oct") for the scrub readout. formatValue: Formats a raw metric value for display. Defaults to locale-aware number formatting. |
width / height / area / interactive | mixed | — | width: Width of the displayed content. Defaults to 160. height: Height of the plot or scroll region in pixels. Defaults to 44. area: Fills the area beneath the trend line. Defaults to true. interactive: Point or arrow along the line to read each value. Default true. |
TrendLine / smoothPath | exports | — | TrendLine renders a raw numeric series with gaps; smoothPath turns point pairs and null gaps into an SVG path. Both remain separate exports. |
style / ref | CSSProperties / native Ref | — | style: Inline styles on the documented visual root; no inline overrides by default. ref: Receives the documented root element; no ref by default. |
classNames | SparklineClassNames | — | Classes for the named visual parts; no part overrides by default. |
trendClassNames | TrendLineClassNames | — | Classes for the trend component's named parts; no overrides by default. |
TrendLine style / ref / classNames | CSSProperties / Ref<HTMLDivElement> / TrendLineClassNames | — | style: On TrendLine: Inline styles on the documented visual root; no inline overrides by default. ref: On TrendLine: Receives the documented root element; no ref by default. classNames: On TrendLine: Classes for the named visual parts; no part overrides by default. |
style | CSSProperties | — | Inline styles on the documented visual root; no inline overrides by default. |
ref | Ref<HTMLElement> | — | Receives the documented root element; no ref by default. |
label (required) | string | — | What it measures: "Signups". |
value | string | — | The headline value (usually the latest). |
change | string | — | "+18%"; its colour follows tone. |
width | number | "fill" | — | Width of the displayed content. Defaults to 160. |
height | number | — | Height of the plot or scroll region in pixels. Defaults to 44. |
labels | string[] | — | A name per point ("Mon", "12 Oct") for the scrub readout. |
formatValue | ((value: number, index: number) => string) | — | Formats a raw metric value for display. Defaults to locale-aware number formatting. |
area | boolean | — | Fills the area beneath the trend line. Defaults to true. |
interactive | boolean | — | Point or arrow along the line to read each value. Default true. |
className | string | — | Classes on the documented visual root; no override by default. |
TrendLine.marker | number | null | — | On TrendLine: The index to mark with a dot and a guide. |
TrendLine.extremes | boolean | — | On TrendLine: Mark the highest and the lowest point; inside a `.reveal-host` they wait for attention. |
Used in
- Agent monitor
- Agent runs monitor
- Analytics dashboard
- Course dashboard
- CRM pipeline
- Email automation
- Invoices
- Market screener
- Order history and fills
- Orders admin
- Portfolio overview
- Product analytics
- Project board
- Sales dashboard
- Training progress
Import
import { TrendLine, Sparkline } from "@beamline/sparkline";
Get it
Sparkline 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…
- Slope chart: 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 (▲ ▼)…
- 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…