KPI card reference

KPI card examples

Contents: Use cases, Chart IDs, Minimal spec, Data, Options, Annotations, Sizing, Fixtures, Not for.

Single-metric card: label, big value, up to two comparison pills, optional attainment, shape-only line/area/column sparkline with last observed value labeled. Type kpi.

Use cases

Chart IDs

One form; its chart ID is kpi.

Minimal spec

{
  "type": "kpi",
  "data": { "label": "Revenue", "value": 120, "delta": { "vs": 100, "scenario": "PY" } },
  "options": { "unit": "$k", "title": "Revenue is $20k above prior year", "source": "Illustrative data" }
}

Data

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

PathTypeRequiredMeaning
labelstringyesName of the metric displayed above the main value. An empty string omits the label and its space.
valuenumberyesMain metric value in its original units.
formatstringFormat-by-example for the main metric and absolute comparison values (a % example expects percent units: 3.53 for 3.53%).
deltaobjectSingle scenario comparison; cannot be combined with compare.
delta.vsnumberyesReference value subtracted from the main metric.
delta.scenariostringAC, PY, PL, FC (or ACT, BUD, FCST, LY for last year). Codes and aliases accept any case. Code of the comparison baseline; a baseline with its own name, such as a month, goes in compare[].label instead.
delta.directionstringWhether an increase from the reference is favorable. neutral prints ordinary ink without a judgment; omission keeps higherIsBetter. One of 'higherIsBetter', 'lowerIsBetter', 'neutral'.
delta.modestringDisplay absolute change, relative change, or both. Defaults to relative; under a percent format it defaults to absolute, which prints in pp. A zero or negative vs shows the absolute change with a ref-nonpositive warning, and a value on the other side of zero from vs shows it with a sign-change warning. One of 'absolute', 'relative', 'both'.
comparearrayOne or two named comparisons below the metric; cannot be combined with delta. An empty compare list is the same as none.
compare[].vsnumberyesReference value for this named comparison.
compare[].labelstringyesVisible name of this comparison baseline.
compare[].directionstringWhether an increase from this reference is favorable. neutral prints ordinary ink without a judgment; omission keeps higherIsBetter. One of 'higherIsBetter', 'lowerIsBetter', 'neutral'.
compare[].modestringDisplay absolute change, relative change, or both. Defaults to both; under a percent format it defaults to absolute, which prints in pp. A zero or negative vs shows the absolute change with a ref-nonpositive warning, and a value on the other side of zero from vs shows it with a sign-change warning. One of 'absolute', 'relative', 'both'.
attainmentobjectRatio of the main value to a named target, displayed as attainment.
attainment.vsnumberyesTarget value used as the attainment denominator.
attainment.labelstringyesVisible name of the attainment target.
attainment.tonestringAttainment tone. Omitted, it is the tone of the comparison against the same reference, else neutral. One of 'good', 'bad', 'warn', 'neutral'.
bandsarrayQualitative bands for the main value, ascending by to. The band that holds the value sets the tone of the main value only; comparison tones stay separate. A band without a tone keeps the plain ink. A band label is added to the screen-reader text and the record.
bands[].tonestringSemantic band tone. One of 'good', 'warn', 'bad', 'neutral'.
bands[].tonumberyesUpper endpoint of this band in the value units.
bands[].labelstringVisible name of this band.
notestringAuthored caption under the value: the basis, filter or scope the number is true of. Printed as written; the card never composes it.
sparkobjectSmall trend chart displayed beneath the KPI comparison content.
spark.kindstringyesShape-only sparkline. 'column' and 'area' are zero-anchored. 'line' spans the series range. The last observed value is labeled unless the card's figure already prints it. No axes. One of 'line', 'area', 'column'.
spark.valuescell[]yesTrend observations in chronological order, in the same base units as the main value; the card format labels the last observed value unless it reads the same as the card's figure. A last value 1000 times or more off the main value is refused (spark-scale-mismatch). Missing cells create gaps.
spark.labelsarrayOne period name per value, such as 'W1' or 'Jan'. The card prints the first and the last under the spark's ends, so the reader sees the span.

Options

PathTypeValuesDefaultMeaning
labelsfalse | objectfalse (or another value of its type)False hides comparisons and spark endpoint values. The main number, metric name and authored note remain. total: false explicitly hides the main number.
columnOverridesobjectSettings per generated column. Ids: label, value.
columnOverrides.*.widthnumberTrack width in px. It beats the width the type would pick.
columnOverrides.*.alignstring'left', 'right', 'center'Alignment of the column: its cell text and, unless headAlign is set, its head. Bars keep starting at the panel origin.
densitystring'compact', 'regular''regular'Card density. 'compact' uses the smaller figure and spark share, and a 280 px default card width instead of 360. An unsized card takes its content height. 'regular' is the default.
comparisonsstring'chip', 'text'How compare[] and attainment are drawn. Omitted, a standalone regular card without a spark draws the steering form: the comparisons as rows of toned text with their names in a column, the attainment as a progress bar with a 100% tick, in one band on a wide card; a grid panel, a compact card, a card with a spark and a card whose height cannot hold the form draw chips. 'chip' tints a chip behind each; 'text' draws each as delta is drawn: text in its tone, no fill, compare entries on one row. colorblindSafe paints good and bad deltas, chips, attainment and value bands with the theme's color-blind pair.

Plus the shared options. This type does not accept detailFields, 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 120 × 28 px; fit content. Narrower than 280 px a card draws while its figure fits.

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
arr-cardexampleARR card with PY delta and area spark
churn-cardexampleNet churn card: lowerIsBetter, negative delta reads good
dual-compareexampleLanding forecast with YoY, plan, and attainment steering chips
chip-comparisonsexamplecomparisons: 'chip' keeps the tinted chips on a standalone card
dual-compare-ref-nonpositivetortureTorture: two nonpositive references show the absolute change in points
value-onlytortureTorture: no delta, no spark — value-only card with action title
unit-beside-valuetortureoptions.unit with no subtitle prints beside the value
vs-zero-guardtortureTorture: vs=0 suppresses relative delta with ref-nonpositive
wide-value-long-labeltortureTorture: long label + $12,345,678,901 value forces font shrink
spark-nullstortureTorture: sparkline with null gaps breaks the line
spark-columntortureTorture: column sparkline with a gap and last-value label
mode-bothtortureTorture: delta mode 'both' — percent and absolute in one pill
content-width-comparisonsexampleKPI card stays within 420px in a wide host with comparisons and a spark
torture-long-labelstortureTorture: long names at a generous size read whole, never cut
note-and-compactexampleCompact card pinned at 280 x 124, with the basis written under the value
text-comparisonstortureTwo comparisons as toned text with carets, one worse and one better, no chips
editorial-figureexampleEditorial card: a light serif figure from type.figure over text comparisons and a text attainment
spark-ink-pale-neutralexampleA line spark in the ink on a theme whose neutral is a pale sand
spark-area-as-lineexampleAn area spark drawn as a shape-only line ending in a ring, no wash and no end label
spark-area-from-minexampleAn area spark whose scale and wash start at the series minimum
house-eyebrowexampleTracked eyebrow from type.eyebrow, comparisons without carets
weekly-orders-card-sparkexampleThe bare weekly sparkline inside a card that names the measure, the period and the number
spark-ends-below-cardexampleCash card: today on the card, month-end balances in the spark, the last one labeled
attainment-bad-column-sparktortureAttainment chip in the bad tone over a monthly column spark
compact-spark-floortortureCompact card keeps its sparkline readable
neutral-changeexampleA change without a favorable direction
slot-natural-sizesexampleA card in a fixed slot that keeps its natural sizes at the top
value-bandsexampleThe band that holds the value colors the main value; the comparison keeps its own tone
column-overridesexamplecolumnOverrides sets the width and alignment of the comparison columns

Not for

Several categories side by side; kpi shows one metric.