Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Gauge

Since 0.1.0-alpha.22
Shows one value against its range, such as progress toward a goal.

Use 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

CPU
Memory
Disk

Code

Usage.razor
@* 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>

@code {
    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:

bash
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

Net Promoter Score, Q3

Code

Range.razor
@* 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

Wind
Gusts44 km/h

Code

Pointers.razor
@* 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 a Gauge's dial or a LinearGauge'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 a Gauge or LinearGauge, on the same scale, such as the dew point beside the temperature: <GaugePointer Value="12" Label="Dew point" />.

Mode support

What works in each mode, Gauge
FeatureStaticInteractive
A 240° dial with the value in the middle and the ends under itYesYes
Bands along the dial that color the fill and name the value's rangeYesYes
A target tick, and more values as pointers on the same dialYesYes
Read as a meter, with its value in wordsYesYes

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 Label says what its color means, on screen and to screen readers.
  • Each GaugePointer is a meter of its own, named by its label, after the gauge's.

Parameters

Gauge parameters
PropTypeDefault
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.doubleRequired
MinThe scale's start.double0
MaxThe scale's end.double1
LabelWhat it measures, such as "Disk used": written with the value, and its accessible name.stringRequired
HideLabelHides the label, which still names the gauge for screen readers.boolfalse
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

See 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.

Connection lost

Rejoining the server…