Dashboard
Description
A KPI scorecard built from sparklines, deltas and target bars
This page is a recipe, not a component. A scorecard row answers four questions about a metric: what is the trend, what is the figure, what changed since last week, and how far along is it against its target. Each question has one component:
| Question | Component |
|---|---|
| The trend | Sparkline, with EndMarker() and ReferenceLine() |
| The change | TrendBadge, usually TrendBadge.For(change, text, higherIsBetter) |
| Progress against a target | TargetBar |
| The rows themselves | DataTable, one component per column |
| Legend and counts | Chip with Pill() and Dot(color) |
DataTable shows the components you hand it. It has no sorting, selection or paging; use DetailsList when a table needs those. Below 640px wide it scrolls sideways. Add every Column(...) before the first Row(...). A row can take a CSS color as its first argument, which draws an accent on its leading edge.
Two rules keep a scorecard readable:
- Color by status, not by direction. A falling cost is good news and a falling revenue is bad news.
TrendBadge.For(change, text, higherIsBetter)derives the arrow from the sign of the change and the color from which way is better, so the same arrow can be green or red. A metric with no target stays gray: call.Neutral()on the badge and useTargetBar(0).NoValue("Context"). - Use one status color for the row accent, the sparkline and the target bar, so the row reads as one signal.
TargetBar(value, target = 100, max = 150) fills the bar up to value and draws a tick at target on the same scale. A value past its target still shows how far over it went while the tick stays put.
Samples
A two-row scorecard
Each row below pairs a fixed 52-point series with a figure, a change and a run-rate bar. The chips above the table are the legend.