Carbon µPlot

Informational — no thresholds

Custom color

Custom range — no ticks, valueFormat

Thresholds — low healthy, high critical

Error rate — custom range, thresholds

No ticks

Inverted thresholds — high is healthy

Inverted thresholds — low free memory

p99 latency — custom range, thresholds

Live — setValue()

Informational — no thresholds


import { createGauge } from 'carbon-uplot';

createGauge(el, {
  value: 42,
  label: 'CPU utilization',
  valueFormat: (value) => `${value}%`,
});

Custom color


import { createGauge } from 'carbon-uplot';

createGauge(el, {
  value: 57,
  ticks: false,
  valueFormat: (value) => `${value}%`,
  color: 'var(--cds-purple-60, #8a3ffc)',
});

Custom range — no ticks, valueFormat


import { createGauge } from 'carbon-uplot';

createGauge(el, {
  value: 1_840,
  min: 0,
  max: 4_096,
  label: 'Disk used',
  ticks: false,
  valueFormat: (value) => `${(value / 1024).toFixed(1)} TB`,
});

Thresholds — low healthy, high critical


import { createGauge } from 'carbon-uplot';

createGauge(el, {
  value: 78,
  label: 'CPU utilization',
  valueFormat: (value) => `${value}%`,
  thresholds: [
    { value: 60, status: 'warning' },
    { value: 85, status: 'error' },
  ],
});

Error rate — custom range, thresholds


import { createGauge } from 'carbon-uplot';

createGauge(el, {
  value: 4.2,
  min: 0,
  max: 10,
  label: 'Error rate',
  valueFormat: (value) => `${value.toFixed(1)}%`,
  thresholds: [
    { value: 2, status: 'warning' },
    { value: 5, status: 'error' },
  ],
});

No ticks


import { createGauge } from 'carbon-uplot';

createGauge(el, {
  value: 63,
  label: 'CPU utilization',
  valueFormat: (value) => `${value}%`,
  ticks: false,
  thresholds: [
    { value: 60, status: 'warning' },
    { value: 85, status: 'error' },
  ],
});

Inverted thresholds — high is healthy


import { createGauge } from 'carbon-uplot';

createGauge(el, {
  value: 68,
  label: 'Memory free',
  valueFormat: (value) => `${value}%`,
  thresholds: [
    { value: 0, status: 'error' },
    { value: 20, status: 'warning' },
    { value: 50, status: 'success' },
  ],
});

Inverted thresholds — low free memory (critical)


import { createGauge } from 'carbon-uplot';

createGauge(el, {
  value: 11,
  label: 'Memory free',
  valueFormat: (value) => `${value}%`,
  thresholds: [
    { value: 0, status: 'error' },
    { value: 20, status: 'warning' },
    { value: 50, status: 'success' },
  ],
});

p99 latency — custom range, thresholds


import { createGauge } from 'carbon-uplot';

createGauge(el, {
  value: 480,
  min: 0,
  max: 1000,
  label: 'p99 latency',
  valueFormat: (value) => `${value}ms`,
  thresholds: [
    { value: 300, status: 'warning' },
    { value: 700, status: 'error' },
  ],
});

Live — setValue()


import { createGauge } from 'carbon-uplot';

const gauge = createGauge(el, {
  value: 45,
  label: 'Memory free (live)',
  valueFormat: (value) => `${value}%`,
  thresholds: [
    { value: 0, status: 'error' },
    { value: 20, status: 'warning' },
    { value: 50, status: 'success' },
  ],
});

let liveValue = 45;
setInterval(() => {
  liveValue = Math.min(100, Math.max(0, liveValue + (Math.random() - 0.48) * 6));
  gauge.setValue({ value: Math.round(liveValue) });
}, 1000);