On this page
@addTagHelper *, Webority.Ui.RazorBasic
A sparkline draws a short trend with no axes, so the shape reads at a glance rather than exact values.
A trend, sized up
Coloured by its surroundings
Range from zero
In a KPI tile
Inside a KPI tile, the trend sits under the value and shows direction without another label.
A tile with a trend
Signups
27
Every option
Every value of every prop, one cell each.
data
data="12,15,14,19,22,21,27": a rising series of seven points
data="5,5,5,5": a flat series, drawn as a midline
data="7": one point, drawn as a midline
data="": empty, draws nothing
data="12,NaN,14": a value that is not a number is left out
label
label="Signups": starts the text alternative, with no visible effect
width
width="48" (default)
width="160": drawn 160 px wide
height
height="16" (default)
height="40": drawn 40 px tall
className
class omitted (default)
class="text-danger" (React: className): a tone class colours the line
trendLabel
trend-label="Trend" (default): the name in the text alternative when no label is given, not drawn
trend-label="Tendance": the name in the text alternative when no label is given, not drawn
namedTrendLabel
named-trend-label="{label} trend" (default): the name in the text alternative when a label is given, not drawn
named-trend-label="{label} tendance": the name in the text alternative when a label is given, not drawn
oneValueText
one-value-text="{name} has one value, {value}." (default): the text alternative for one point, not drawn
one-value-text="{name} has a single reading, {value}.": the text alternative for one point, not drawn
rangeText
range-text="{name} from {from} to {to} across {count} points." (default): the text alternative for a series, not drawn
range-text="{name} runs from {from} to {to}, {count} points.": the text alternative for a series, not drawn
Guidance
What to do, and what to avoid.
Use it when
- The direction of a number matters more than its exact value, in a table row or beside a figure.
- There is room for a word-sized picture and none for axes.
Reach for something else when
- Values that must be read, compared or dated. → AppChart
- One reading against a known range. → AppMeter
Reference
Try every prop, read the full list, and check keyboard and screen reader behaviour.
9 props. The 5 most used come first.
Used on most screens 5 props
| Prop | Type | Default | Description |
|---|---|---|---|
| datadefault - | string | - | The values, comma-separated, in order. An empty series draws nothing; one point or an all-equal series draws a flat midline. |
| labeldefault - | string | - | What the trend measures; it starts the text alternative. |
| widthdefault 48 | int | 48 | Width in px. |
| heightdefault 16 | int | 16 | Height in px. |
| trend-labeldefault Trend | string | Trend | Replaces the built-in English text, for other languages. |
Less common 4 props
| Prop | Type | Default | Description |
|---|---|---|---|
| named-trend-labeldefault {label} trend | string | {label} trend | Replaces the built-in English text, for other languages. The token {label} is the label prop. |
| one-value-textdefault {name} has one value, {value}. | string | {name} has one value, {value}. | Replaces the built-in English text, for other languages. The tokens are {name} (the trend name) and {value} (the one value). |
| range-textdefault {name} from {from} to {to} across {count} points. | string | {name} from {from} to {to} across {count} points. | Replaces the built-in English text, for other languages. The tokens are {name} (the trend name), {from} and {to} (the first and last values) and {count} (the number of points). |
| y-mindefault - | double | - | The lowest value of the line's range. Unset: the lowest data value. |
Screen reader
3 notes- The svg has role img and an aria-label that names the trend and says where the line starts and ends.
- A custom aria-label replaces that text, and aria-hidden set to true hides the sparkline when the figure sits beside it in text.
- A series with no usable value draws nothing.