Gauge
Since 0.1.0-alpha.22Use a gauge to show one value against its range, such as progress toward a goal. It takes a lot of space for one number and has no history. Several readings side by side read better as bullet graphs. Add a sparkline to show the trend.
Bands
Give Gauge a Value and a Label. Each GaugeBand marks a range along the dial's edge in the next of Palette's colors, and a value in it fills in that color.
Static
Preview
Code
@* A server's load against the same two bands: past 70% is high, past 90% critical. Each gauge fills
in the color of the band its value is in, and names the band under the value. *@
<Row Gap="8" Wrap Justify="Justify.Center">
foreach (var (label, value) in _load)
{
<Gauge Label="label" Value="value" ValueFormat="P0" Palette="ChartPalette.Of(Color.Warning, Color.Danger)">
<GaugeBand From="0.7" To="0.9" Label="High" />
<GaugeBand From="0.9" To="1" Label="Critical" />
</Gauge>
}
</Row>
{
private readonly (string Label, double Value)[] _load = [("CPU", 0.42), ("Memory", 0.78), ("Disk", 0.93)];
}Add this example to a page with the izzy CLI:
izzy add component Gauge --at <file>:<line>The dial runs from Min to Max, 0 to 1 by default, so a share reads as a percent with ValueFormat="P0". A gauge is 12rem wide; Width sets another.
A dial alone is a number in a ring; bands give the value something to be read against. A band's Label shows under the value, so the color isn't the only cue.
A band's own Accent takes the place of its palette color, such as Accent="Accent.Danger" on one band among grays.
Range and target
To measure on another scale, set Min and Max. Target marks a goal with a tick across the dial, read with the value as "target 50". A value past either end fills none or all of the dial, and still shows as it is.
Static
Preview
Code
@* Net Promoter Score runs from −100 to 100; the team's goal this quarter is 50. The bands are the
usual reading of a score, in the default grays: they mark the ranges, the label says which. *@
<Gauge Label="Net Promoter Score, Q3" Value="42" Min="-100" Max="100" Target="50">
<GaugeBand From="-100" To="0" Label="Needs work" />
<GaugeBand From="0" To="30" Label="Good" />
<GaugeBand From="30" To="70" Label="Great" />
<GaugeBand From="70" To="100" Label="Excellent" />
</Gauge>Without a Palette, bands are grays, darkest first: they mark the ranges without calling one good or bad, and the value keeps the primary color. The band's label names where it falls.
Pointers
For another value on the same dial, such as the gusts beside the mean wind, write a GaugePointer inside the gauge with its Value and Label. It's written under the label as "Gusts 44 km/h".
Static
Preview
Code
@* Wind at a weather station: the ten-minute mean fills the dial, and the strongest gust in that
time is a pointer on the same scale. *@
<Gauge Label="Wind" Value="27" Max="100" ValueFormat="0 km/h">
<GaugeBand From="39" To="62" Label="Strong" />
<GaugeBand From="62" To="100" Label="Gale" />
<GaugePointer Value="44" Label="Gusts" />
</Gauge>The gauge's own Value stays the one that fills. Each pointer is a meter of its own, named by its label; its Accent sets another color.
For one goal, Target is simpler: a tick in the text color, read with the value.
Details
12rem wide unless Width says otherwise, and never wider than its container.
Bands mark ranges along the dial's outer edge, in grays (darkest first) unless Palette or a band's Accent colors them; a value in a colored band fills in its color, and shows its label. Target marks a goal with a tick across the track. Each GaugePointer is another value on the same dial, a notch in its color, written under the label: "Dew point 12°".
Parts
Written inside Gauge. The API page lists their parameters.
GaugeBand: a range on aGauge's dial or aLinearGauge's scale, such as where a load turns high:<GaugeBand From="0.7" To="0.9" Accent="Accent.From(Color.Warning)" Label="High" />.GaugePointer: another value on aGaugeorLinearGauge, on the same scale, such as the dew point beside the temperature:<GaugePointer Value="12" Label="Dew point" />.
Mode support
| Feature | Static | Interactive |
|---|---|---|
| A 240° dial with the value in the middle and the ends under it | Yes | Yes |
| Bands along the dial that color the fill and name the value's range | Yes | Yes |
| A target tick, and more values as pointers on the same dial | Yes | Yes |
| Read as a meter, with its value in words | Yes | Yes |
Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.
Accessibility
- role="meter", named by
Label, which is required, with aria-valuenow, -min and -max, and the formatted value as aria-valuetext with its band's label and the target, so a screen reader hears "Disk used, 72%, High, target 80%". - Colors aren't read: a band's
Labelsays what its color means, on screen and to screen readers. - Each
GaugePointeris a meter of its own, named by its label, after the gauge's.
Parameters
| Prop | Type | Default |
|---|---|---|
RefreshHow often the gauge reads its data again, at least a second, such as Refresh="TimeSpan.FromSeconds(30)". | TimeSpan? | |
RefreshFromOn a static page with Refresh: a lighter page to fetch than this one, which renders the same gauge with the same id. | string? | |
ValueThe value. | double | Required |
MinThe scale's start. | double | 0 |
MaxThe scale's end. | double | 1 |
LabelWhat it measures, such as "Disk used": written with the value, and its accessible name. | string | Required |
HideLabelHides the label, which still names the gauge for screen readers. | bool | false |
ValueFormatA .NET format string for the value, the scale's numbers, the target and the pointers, such as P0, N0 or 0 mb. | string? | |
TargetA goal to read the value against, such as 0.8: a tick across the track, read with the value. | double? | |
AccentThe value's color, such as Accent.Of("#0d9488"). | Accent? | computed |
PaletteThe bands' colors, in the order they're written, such as ChartPalette.Of(Color.Warning, Color.Danger), or ChartPalette.Tints(Color.Warning) for a light tint up to the full color (for a thick track's bands). | ChartPalette? | computed |
ChildContentThe GaugeBands, ranges along the scale such as where a load turns high, and GaugePointers, more values on the same scale. | RenderFragment? | |
OnRefreshOn an interactive page with Refresh: raised at each interval, to load new data. | EventCallback |
Plus 17 item props and 4 common props.
Full APISee also
- LinearGauge: shows one reading on a scale, such as a tank's level or the air pressure.
- Progress: shows a progress bar, with or without a known value.
- Stat: shows a figure with its trend, read as words.