Gauge
A value against its target on a half ring. The state is a word, the target a mark.
import { Gauge, dashboardGaugeState } from "@forgeron/ui";36kof 50k · 72%Close
- Behindunder 35k
- Close35k to 50k
- On target50k and over
import { Gauge } from "@forgeron/ui";
export default function Default() {
return <Gauge title="Quarterly quota" value={36} target={50} format={(n) => `${n}k`} />;
}5.5 hof 4 h · 138%Slow
- Fast0 h to 4 h
- Slow4 h to 8 h
- Late8 h and over
// Lower is better here: the states are written for it.
import { Gauge } from "@forgeron/ui";
export default function Thresholds() {
return (
<Gauge
title="First response, hours"
value={5.5}
target={4}
min={0}
max={12}
format={(n) => `${n} h`}
thresholds={[
{ at: 0, label: "Fast", tone: "good" },
{ at: 4, label: "Slow", tone: "warn" },
{ at: 8, label: "Late", tone: "bad" },
]}
/>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | — | Names the gauge. |
value | number | — | Where it stands now. |
target | number | — | What it should reach. |
min / max | number | 0 / a quarter above | The scale. max defaults to a quarter above the larger of value and target. |
thresholds | { at, label, tone }[] | Behind, Close, On target | States from the value at which each starts; tone is bad, warn or good. Say a state in words. |
format | (value: number) => string | String | Writes a value. |
size | number | 200 | Width, in px. |
className | string | — | Extra classes. |