Gauges
A gauge shows one value on a scale from a minimum to a maximum: the load on a server, how full a disk is, how much of a goal is reached. The value is written large in the middle; colored ranges and a target show what it means.
One value
Give GaugeSeries a Value and a Max (Min defaults to 0). The scale runs from
-120° to 120° unless you set StartAngle and EndAngle. ColorBands color the scale's ranges
in a thin ring outside the track, and the value takes the color of the range it is in. Target marks a target across
the scale and adds it to the tooltip. A new Value draws the gauge again: drag the slider.
Code
<RioChart TItem="object" Title="CPU load">
<GaugeSeries Name="Web server" Value="cpu" Max="100" Target="70" Format="0'%'" ColorBands="load" />
</RioChart>
@code {
double cpu = 64;
ColorBand[] load =
[
new() { Above = 60, Color = "--rio-series-2" },
new() { Above = 85, Color = "--rio-negative" },
];
}A gauge per item
With Items, XValue and YValue every item is a gauge, labeled by its x, laid out in the grid
that makes them largest. Here StartAngle="-90" and EndAngle="90" make half circles. Several
GaugeSeries also make a gauge each, each with its own scale, format and color.
Code
<RioChart TItem="Drive" Items="drives" Title="Disk use">
<GaugeSeries XValue="d => d.Name" YValue="d => d.Used" Max="100" StartAngle="-90" EndAngle="90" Format="0'%'"
ColorBands="[new() { Above = 90, Color = "--rio-negative" }]" />
</RioChart>
@code {
record Drive(string Name, double Used);
}In JSON definitions
"type": "gauge" (also meter and dial) with a "y" field, and "min",
"max", "target" and "colorBands". Without x the gauge shows one value from the rows:
the last, or the aggregate (e.g. average); with x or groupBy there is one gauge per value.
{ "dataset": "servers", "series": [ { "type": "gauge", "y": "cpu", "aggregate": "average", "max": 100, "target": 70,
"colorBands": [ { "above": 60, "color": "--rio-series-2" }, { "above": 85, "color": "--rio-negative" } ] } ] }