Skip to content

PlGaugeChart

One number on a scale that is known in advance, drawn as a dial. A PlMeter bent into an arc, for a tile of its own rather than a row of fields.

React
tsx
import { PlGaugeChart } from 'plass-ui';

<PlGaugeChart value={68} caption="of quota" />;
dart
import 'package:plass_ui/plass_ui.dart';

PlGaugeChart(value: 68, caption: Text('of quota'));

value, min, max and thresholds mean exactly what they mean on a meter, so a page can move a reading from a bar to a dial without changing what it says. Reach for the bar in a row of fields and for this one where a dial reads at a glance from across a room and a four-pixel bar does not.

It is not a pie chart with shape="semi". A pie is parts of a whole and every slice is a category; this is one value against a scale, and the unfilled part of the arc is not a second category. It is the rest of the dial.

Props

PropTypeDefaultDescription
value * number | nullThe reading. null draws the dial with nothing on it
minnumber0The bottom of the scale
maxnumber100And the top of it
sweepnumber180How far round the dial goes, in degrees, opened symmetrically about twelve
thicknessnumber0.22How thick the arc is, as a fraction of its radius
thresholdsreadonly PlassThreshold[]Where the arc changes colour. The meter's rule: the highest band at or below the value wins
ticksnumber | falsefalseHow many marks are drawn around the dial, ends included
showRangebooleantrueWrites min and max at the two ends. Dropped past 330 degrees whatever it says
centerReactNodeWhat goes in the middle. Left out, it is the value written through format
captionReactNodeA line under the value: the unit, or what is being measured
heightnumber | stringHow tall the drawing is
formatIntl.NumberFormatOptionsHow a value is written
labelstringWhat the dial is called. Without one it stays a plain box
emptyReactNodeWhat is drawn when there is nothing to draw
colorshared'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info''primary'The family the arc takes where no threshold applies
sizeshared'xs' | 'sm' | 'md' | 'lg' | 'xl''md'Type scale and dial height
PropTypeDefaultDescription
value * double?The reading. null draws the dial with nothing on it
mindouble0The bottom of the scale
maxdouble100And the top of it
sweepdouble180How far round the dial goes, in degrees, opened symmetrically about twelve
thicknessdouble0.22How thick the arc is, as a fraction of its radius
thresholdsList<PlassThreshold>?Where the arc changes colour. The meter's rule: the highest band at or below the value wins
ticksint?falseHow many marks are drawn around the dial. null is off, where React writes false
showRangebooltrueWrites min and max at the two ends. Dropped past 330 degrees whatever it says
centerWidget?What goes in the middle. Left out, it is the value written through format
captionWidget?A line under the value: the unit, or what is being measured
heightdouble?How tall the drawing is
formatString Function(double)?How a value is written
semanticLabelString?What the dial is called. Without one it stays a plain box
emptyWidget?What is drawn when there is nothing to draw
colorsharedPlassColorPlassColor.primaryThe family the arc takes where no threshold applies
sizesharedPlassSizePlassSize.mdType scale and dial height

A null value draws the dial with nothing on it, which is the honest picture of an instrument that has not been told anything. There is no legend and no tooltip: one number needs neither.

What the shared props mean across the library is in prop conventions.

Examples

sweep

React

Degrees, opened symmetrically about twelve o'clock. 180 is the half-dial for a dashboard tile, 270 is the instrument shape, 360 is a ring.

The dial is sized against the box rather than assuming a circle, because how far it reaches below its centre depends on the sweep: a half-dial stops level with the centre and a 270° one drops most of a radius past it. That is what keeps a wide, short card from drawing a thin band with an empty half above it.

thresholds

React

The highest band at or below the value wins, and color is what the arc is made of below all of them. Order in the list does not matter (the bands are read, not walked), which is the same rule and the same code a PlMeter uses.

A band is a second way of saying the number, never the only one. The reading is written in the middle whatever colour the arc has taken.

ticks and showRange

React

Ticks are off by default. A gauge on a dashboard is read as a proportion, and marks around the rim are for an instrument somebody takes a number off.

showRange writes min and max at the two ends, and is dropped past 330° whatever it says: by then the two ends have come within a label's width of each other, and 0 and 100 set on top of each other is a smudge rather than a scale.

center and caption

center replaces the number in the hole, and caption hangs a line under it. Replacing the reading is for adding to it rather than for taking it away. The number is what the dial is for.

The reading is real text, not a label painted into the drawing, so it can be selected, found by the browser's own search and read without the chart having to describe itself. Its size is solved against the room the hole actually leaves rather than fixed, because 38 and 10,000% are the same prop.

Accessibility

  • With a label the dial is one named image saying one thing: "Storage used: 1.36 / 2". That saves a reader hearing the two end labels as loose numbers.
  • Without one it stays a plain box, and the reading in the middle is read as the text it already is.
  • The value is never carried by colour alone. A threshold changes the family; the number in the middle says the same thing in words.
  • The arc sweeps to a new reading rather than jumping to it, and the sweep is a length rather than a transform. The numbers written across the dial are never resampled.

Released under the MIT License