Gauge

View as Markdown

One reading on a half dial, with bands that say whether it's fine and a mark for the target.

When to use

One reading on a half dial, with bands that say whether it's fine and a mark for the target. Use Meter instead when the value sits in a row, not on its own.

Usage

import { Gauge } from "./ui/uicontext/components/charts/Gauge.ts"
export const Storage = <M>(h: Html.H<M>) =>	Gauge(h, { label: "Disk", value: 0.62, max: 1, format: { style: "percent" }, bands: [{ upTo: 0.8, tone: "good", label: "OK" }, { upTo: 1, tone: "danger", label: "Nearly full" }] })

Examples

A score against a goal

Without bands the arc takes the first chart color. target marks the goal on the track.

API reference

Options

Gauge options
NameTypeDefaultDescription
labelrequiredstring—What's measured: "p95 latency"
valuerequirednumber——
minnumber——
maxrequirednumber——
formatChartFormat——
bandsGaugeBand[]—Stretches of the track that mean something, low to high
targetnumber—A goal, marked with a tick on the track
sizenumber200Pixels wide; 200 by default
localestring——
styleStyle——

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/gauge

Source