Reference

Sparkline

A tiny chart in a line of text — a line, or .bar — of a list of numbers, drawn as an SVG when the page is built.

Sparkline(_ data: [Number], bar: Bool, width: Number, height: Number, …)

Since 6.2.0

bar

Sign-ups this week

Errors by day

Example

wf

Stack(gap: .sm) { Row(gap: .sm, align: .center) { Text("Sign-ups this week") Sparkline([12, 18, 9, 24, 31, 27, 40], label: "Sign-ups this week") } Row(gap: .sm, align: .center) { Text("Errors by day") Sparkline([4, 2, 7, 1, 0, 3, 2], label: "Errors by day").bar } }

Its size and colour

wf

Sparkline([3, 5, 4, 8, 6, 9], label: "Latency", width: 160, height: 32, color: "#0F766E")

Related:

Chart QrCode Stat

Props

Props of Sparkline
PropTypeUnsetMeaning

data

[Number] (positional)

—

The numbers, a list, drawn as an SVG when the page is built, so they must be known then (E109 otherwise); scaled from the least to the most

bar:

Bool

false

Bars from zero rather than a line. Written as a flag, .bar, or bar: true.

width:

Number

80

Its width in px; 0 or less is the default

height:

Number

20

Its height in px; 0 or less is the default

color:

String

the text's colour

The line's or the bars' colour, a CSS colour (#0F766E, var(--color-primary)); anything else is the default, the text's colour (currentColor)

label:

String

Trend

What it shows, as the picture's accessible name (role="img")

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

.bar

Events

Every element also takes the props, the events and the attribute families listed on every element.

Slots

It takes no slots.

Renders with the class wf-sparkline, stable across releases, so a stylesheet may target it.

These controls list the props' cases; the example below shows them written.