Sparkline chart reference

Sparkline examples

One series as a 176 by 36 mini line — no axes, no smoothing, no fill, a ring on the last point. Type sparkline.

Use cases

Chart IDs

One form; its chart ID is sparkline.

Minimal spec

{
  "type": "sparkline",
  "data": { "values": [112, 114.2, 113.1, 116.8, 118.4], "labels": ["May", "Jun", "Jul", "Aug", "Sep"] },
  "options": { "format": "1.1", "title": "Orders climb through the summer", "source": "Illustrative data" }
}

Data

A cell is a number, null or a value object; see Value cell.

PathTypeRequiredMeaning
valueKindstringMultiply numbers by 100 into pct cells; explicit pct cells stay in percent units. One of 'fraction'.
valuescell[]yesThe series in order, at least two points. A null is bridged by a dotted segment with a ring on the missing point.
labelsarrayOne name per value, in the same order. The end labels and the hover records read them; without them a point is named by its position.
labelstringName of the metric the line shows, such as "Orders", as label names a KPI. The hover card names each value with it ("Orders: 18"); nothing on the chart prints it.

Options

PathTypeValuesDefaultMeaning
ringstring'last', 'none''last'A ring on the last observed point, in the highlight. 'last' is the default; 'none' draws the bare line.
endLabelsstring'ends', 'none''none''ends' prints the first and last authored label under the ends of the line, at the micro step in the muted ink. Default 'none'. The key is endLabels because labels is the shared per-label-kind switch. The labels take one text line of the height, about half of a 36 px card, so the line and a reference inside its range share the rest. Use 'none' on a short card, or when a reference must read apart from the line.
valueLabelstring'last', 'last-and-high', 'none''none''last' prints the last observed value beside the end of the line, in the format. On a framed sparkline (title, subtitle or source) whose line band keeps 60 px, it also marks the high point with a dot and its value, muted, above it, unless the last point is the high; then it also marks the low under its point (unless the low is the last point) and the first value away from the line (unless the first point is the high or the low), and a reference prints its value in the column of the last value, level with the dashed line. 'last-and-high' keeps the last value and the high only. Default 'none': a card that hosts the bare mark prints the figure itself.
strokenumber2Stroke width of the line in px. Default uses the theme stroke.data token (2 px).
referencenumberA 1 px dashed line at this value in the muted ink. The scale always includes it. On a framed sparkline with valueLabel 'last' its value prints in the column of the last value, muted.
ringTonestring'good', 'warn', 'bad'Paints the end ring in this tone instead of the highlight. Refused with ring 'none'.

Plus the shared options. This type does not accept detailFields, labels, labelPosition, valueAxis, story, hatchStrength, rounding, annotations. This type ignores animate, debug, rowLabels, categoryAxis, categoryLabels, secondaryAxis, sort, topN, bandFraction, legend, valueAxis.show, valueAxis.gridlines with an option-ignored warning.

Annotations

This type takes no annotations.

Sizing

Floor 88 × 24 px; fit content.

Below the floor a render is refused with size-below-floor and the pixels it needs. measure returns the natural and comfortable size for a given spec; see Sizing in the manual.

Fixtures

IDKindUse case
orders-nine-monthsexampleNine months of orders, the last point ringed and valued, both ends named
bare-card-sparkexampleThe bare 176 by 36 mark: no end ring, no labels, a null bridged by a dotted segment
orders-heavy-stroketortureA 2.5 px line instead of the default 1.5 px
orders-last-and-hightorturevalueLabel 'last-and-high': the last value and the high, as before the low and first values were named
reference-above-dataexampleA target above every point: the scale reaches up to the reference, the ring in warn
reference-inside-dataexampleA reference the line crosses twice, the ring in good
reference-constant-valuesexampleA flat series under its reference: the line sits at the foot, the ring in bad
reference-with-gapsexampleA reference under a series with two gaps, bridged and ringed

Not for

A chart a reader takes numbers off; a sparkline states a shape and nothing else.