Blocks / Gauge

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";
/01 → Default
Quarterly quota
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`} />;
}
/02 → Thresholds
First response, hours
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
PropTypeDefaultDescription
titlestring—Names the gauge.
valuenumber—Where it stands now.
targetnumber—What it should reach.
min / maxnumber0 / a quarter aboveThe scale. max defaults to a quarter above the larger of value and target.
thresholds{ at, label, tone }[]Behind, Close, On targetStates from the value at which each starts; tone is bad, warn or good. Say a state in words.
format(value: number) => stringStringWrites a value.
sizenumber200Width, in px.
classNamestring—Extra classes.