Gauge Chart
Show one value on a fixed scale, with optional ranges that say whether it is good or bad.
Overview
A gauge shows a single value on a scale with a known minimum and maximum, such as a score, a utilisation percentage, or progress toward a target. Bands mark the ranges that matter, so readers see at once whether the value is normal or needs attention. A gauge takes a lot of space for one number: use a stat with a Radial Chart ring for several progress values, or a line chart when the trend matters more than the current reading.
Anatomy
GaugeChart owns the value, scale, and loading state. Arc sets the sweep (semi, three-quarter arc, or full) and thickness. Bands draws colored ranges in a thin outer ring and, by default, colors the value with the range it falls in. Ticks marks the scale, Needle adds a pointer, Center prints the value as HTML in the middle, and Legend names the bands.
Accessibility
The plot is exposed as a meter with aria-valuemin, aria-valuemax, aria-valuenow, and a value text that includes the band name, so assistive technology reads the value directly. The band colors are paired with a band name in the center caption and the legend. Pass ariaLabel to give the meter a more specific name.
Installation
Usage
import { GaugeChart, type ChartConfig } from "honestui/charts";const chartConfig = {
target: { label: "of monthly target", colors: { light: ["#3b82f6"], dark: ["#60a5fa"] } },
} satisfies ChartConfig;<GaugeChart value={72} max={100} dataKey="target" config={chartConfig}>
<GaugeChart.Arc type="semi" thickness={16} />
<GaugeChart.Center valueFormatter={(value) => `${value}%`} />
</GaugeChart>dataKey names the config entry that labels and colors the value. Values outside min and max are clamped on the arc; the center still prints the real value. A new value eases from the previous one rather than redrawing from the minimum.
Examples
Bands and ticks
Each band runs up to its to value and takes its color and name from config. The value arc and the center caption follow the band the value falls in; set colorProgress={false} to keep the dataKey color.
Needle
Needle adds a pointer. The readout moves below the pivot so the needle never crosses it. Step the reading to see the value ease between updates.