Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

Basic

A sparkline draws a short trend with no axes, so the shape reads at a glance rather than exact values.

A trend, sized up
Show code
<app-sparkline data="12,15,14,19,22,21,27" label="Signups" width="160" height="40" />
Coloured by its surroundings
Show code
<span class="text-danger"><app-sparkline data="40,38,35,36,30,27,22" label="Churn" width="96" height="24" /></span>
Range from zero
Show code
<app-sparkline data="40,42,41,44,43,45" y-min="0" />

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
Show code
<app-kpi-tile label="Signups" value="27" sparkline="12,15,14,19,22,21,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.

Rising (7 points) Falling (7 points) Flat series One point Empty
React, generated from the controls
<AppSparkline data={data} label="Signups" />
Razor, the same props
<app-sparkline data="12,15,14,19,22,21,27" label="Signups" />

9 props. The 5 most used come first.

Used on most screens 5 props

PropTypeDefaultDescription
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

PropTypeDefaultDescription
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.