GaugeChart

Molecule

Gauge (role="meter") rendered on the server. Five layouts: `arc` (half circle, default), `donut` (an arc between `startAngle` / `endAngle`), `bar-horizontal`, `bar-vertical` and `level` (a thermometer). Threshold `bands` (`from` / `to`, `tone` or any `color`, `label`) drawn as a thin outer ring (`bandStyle: 'outer'`, default) or tinted on the track; `bandEdges` decides boundary values, `bandDisplay` whether bands colour the bar, the track or both. Needle styles `line`, `arrow`, `marker`; evenly spaced `ticks` with `tickLabels`; `thickness`, `roundedCaps`, `color`, `trackColor`; sizes sm / md / lg / `fill`; a stale state for readings that stopped updating. Every text (value, caption, min / max, ticks) is HTML over the SVG, so it keeps the kit's type sizes. Part of the Chart library (`modules/ui/Chart/Chart.ejs`, `type: 'gauge'`).

Threshold bands

Preview

CPU 34% (success band), Disk 91% (error band)

34% CPU
0 100
91% Disk
0 100
Code
<%- include('modules/ui/Chart/Chart', { type: 'gauge', value: 34, unit: '%', label: 'CPU', bands: bands }) %>
<%- include('modules/ui/Chart/Chart', { type: 'gauge', value: 91, unit: '%', label: 'Disk', bands: bands }) %>

Needle

Preview

Disk 91% with a needle

91% Disk
0 100
Code
<%- include('modules/ui/Chart/Chart', { type: 'gauge', value: 91, min: 0, max: 100, unit: '%', label: 'Disk', needle: true, bands: bands }) %>

Layouts

Preview

donut with an arrow, horizontal bar with ticks, vertical bar, level with a marker

72% Memory
0 100
64% Battery
0100 255075
0100
38L Tank
-1040
21°C Room
Code
<%- include('modules/ui/Chart/Chart', { type: 'gauge', layout: 'donut', value: 72, unit: '%', needle: true, needleStyle: 'arrow', bands: bands }) %>
<%- include('modules/ui/Chart/Chart', { type: 'gauge', layout: 'bar-horizontal', value: 64, ticks: 5, tickLabels: true, bands: bands }) %>
<%- include('modules/ui/Chart/Chart', { type: 'gauge', layout: 'bar-vertical', value: 38, unit: 'L', roundedCaps: true }) %>
<%- include('modules/ui/Chart/Chart', { type: 'gauge', layout: 'level', value: 21, min: -10, max: 40, needle: true, needleStyle: 'marker', color: 'var(--error)' }) %>

Stale reading

Preview

The value stopped updating

72 Stale reading
0 100
stale
Code
<%- include('modules/ui/Chart/Chart', { type: 'gauge', value: 72, size: 'sm', label: 'Stale reading', stale: true }) %>

Sizes

Preview

sm, md, lg at 55%

55% sm
0 100
55% md
0 100
55% lg
0 100
Code
<%- include('modules/ui/Chart/Chart', { type: 'gauge', value: 55, unit: '%', label: 'sm', size: 'sm', bands: bands }) %>
<%- include('modules/ui/Chart/Chart', { type: 'gauge', value: 55, unit: '%', label: 'md', size: 'md', bands: bands }) %>
<%- include('modules/ui/Chart/Chart', { type: 'gauge', value: 55, unit: '%', label: 'lg', size: 'lg', bands: bands }) %>
Source modules/ui/Chart/partials/_gauge.ejs