MDK Logo
UI Kitreact-devkitComponentsCoreCharts

GaugeChart

GaugeChart - Presentational gauge / speedometer chart. Implementation note: this component used to wrap the `react-gauge-chart` NPM package, but that package…

GaugeChart - Presentational gauge / speedometer chart.

Implementation note: this component used to wrap the react-gauge-chart NPM package, but that package is published only as CommonJS with a broken module field that points at the same CJS file. That made it crash under ESM bundlers that don't add a __esModule ? .default : module interop shim (Webpack 4, raw esbuild, certain SSR setups, etc.) with React's "Element type is invalid" error. We replaced it with a pure-SVG internal implementation (see ./gauge-svg.tsx) so the component is bundler- and runtime-agnostic and has zero third-party runtime dependencies.

import { GaugeChart } from "@tetherto/mdk-react-devkit";
PropStatusTypeDefaultDescription
percentRequirednumberValue between 0 and 1 (e.g. 0.75 = 75%). Values outside the range are clamped.
colorsOptionalstring[] | undefinedArc colours in HEX format.
arcWidthOptionalnumber | undefinedArc thickness as a fraction of the gauge radius (0–1).
nrOfLevelsOptionalnumber | undefinedNumber of arc segments.
hideTextOptionalboolean | undefinedHide the percentage text rendered inside the gauge.
idOptionalstring | undefinedStable id used for the gauge's accessibility labels.
heightOptionalstring | number | undefinedChart height in pixels or any CSS length (e.g. `'200px'` or `'50%'`).
maxWidthOptionalnumber | undefinedMaximum width in pixels.
classNameOptionalstring | undefined

Usage

A gauge / speedometer chart rendered via react-gauge-chart. Accepts a percent value between 0 and 1 and displays it as a colored arc.

Notes

  • percent is automatically clamped to [0, 1].
  • When rendering multiple gauges on the same page, provide a unique id for each instance to prevent react-gauge-chart rendering conflicts.

Example

/** * Runnable example for GaugeChart. */import { GaugeChart } from '@tetherto/mdk-react-devkit'export const GaugeChartExample = () => (  <div className="mdk-example-row">    <GaugeChart percent={0.72} id="gauge-hash-rate" />    <GaugeChart      percent={0.45}      id="gauge-efficiency"      colors={['#34C759', '#FF9500', '#FF3B30']}      nrOfLevels={5}    />    <GaugeChart percent={0.95} id="gauge-uptime" hideText height={160} />  </div>)