Sparkline

A word-sized trend line with its latest, lowest and highest points.

  • Recurring revenue$296.8K
  • Weekly signups859
  • p95 latency, hourly256 ms

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/sparkline

Usage

import { Sparkline } from "./ui/uicontext/components/charts/Sparkline.ts"
export const SignupTrend = <M>(h: Html.H<M>, weekly: ReadonlyArray<number>) =>	Sparkline(h, { values: weekly, label: "Signups, last 12 weeks" })

Examples

Fill the width

Stretches with its container and keeps a crisp line.

API reference

Options

Sparkline options
NameTypeDefaultDescription
valuesrequiredReadonlyArray<number | null>——
labelrequiredstring—What it shows, for its accessible name: "Signups, last 12 weeks"
formatChartFormat——
widthnumber | "fill"96Pixels, or "fill" to take its container's width. 96 by default
heightnumber24Pixels; 24 by default
areaboolean—A soft fill under the line
extremesboolean—Dots on the lowest and highest values
colorChartColor——
localestring——
styleStyle——

Accessibility

  • A sparkline is one image whose name says where the trend went: from, to, low and high.

Source