Charts
GaugeNew in 0.7.0
RadialGauge and LinearGauge show one value against a range — color bands, a target marker, ticks, and fully replaceable center content.
RadialGaugeLinearGaugePreview
Value 68
Thickness 14px
68%CPU
Disk usage68% (32% free)
0%100%
Usage
tsx
import { RadialGauge, LinearGauge } from "@vesture/react";
const bands = [
{ from: 0, to: 60, color: "#008300" },
{ from: 60, to: 85, color: "#eda100" },
{ from: 85, to: 100, color: "#e34948" },
];
<RadialGauge value={72} label="CPU" ranges={bands} ticks={6} showTickLabels target={90} formatValue={(v) => `${v}%`} />
<RadialGauge value={72} sweep={360} startAngle={-90} renderCenter={({ formatted }) => <strong>{formatted}%</strong>} />
<LinearGauge value={58} label="Quota" target={75} thickness={14} />Behavior
- ranges are color bands ({ from, to, color }); the fill takes the color of the band the value falls in, falling back to color and then the theme primary.
- RadialGauge's startAngle and sweep reshape the dial: 270° (default) is a classic speedometer, 180° a half-dial, 360° a full progress ring. thickness, squareCaps and trackColor tune the stroke.
- ticks adds evenly spaced tick marks (showTickLabels prints their values); target draws a marker at a goal or SLA threshold on either gauge.
- renderCenter on the dial and renderValue on the bar replace the default readout with anything — icons, units, secondary values.
- Values outside min/max are clamped visually; the real value still goes to aria-valuenow.
Props
Shared
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | — | Required. |
| min / max | number | 0 / 100 | |
| ranges | { from: number; to: number; color: string }[] | — | Color bands. |
| color | string | — | Fill when no range matches. |
| trackColor | string | — | Unfilled track. |
| target | number | — | Marker at this value. |
| label | string | — | Also the accessible name. |
| formatValue | (value: number) => string | String |
RadialGauge
| Prop | Type | Default | Description |
|---|---|---|---|
| size | number | 160 | Diameter in px. |
| startAngle | number | 135 | Degrees clockwise from 3 o'clock. |
| sweep | number | 270 | Degrees the dial spans (up to 360). |
| thickness | number | — | Stroke width; defaults to 9% of size. |
| squareCaps | boolean | false | Flat instead of rounded ends. |
| ticks | number | 0 | Tick count including both ends. |
| showTickLabels | boolean | false | |
| renderCenter | ({ value, fraction, color, formatted }) => ReactNode | — | Replaces the center readout. |
LinearGauge
| Prop | Type | Default | Description |
|---|---|---|---|
| thickness | number | 10 | Bar height in px. |
| showScale | boolean | true | Min/max labels under the bar. |
| squareCaps | boolean | false | |
| renderValue | ({ value, fraction, formatted }) => ReactNode | — | Replaces the header's value text. |