# C gauge chart 2

> CPU load — value arcs coloured by threshold

A shadcn/ui block from the [@cnippet](https://ui.cnippet.dev/?utm_source=shadcn.exchange) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/cnippet/c-gauge-chart-2).

- Page, with a live preview: https://shadcn.exchange/r/cnippet/c-gauge-chart-2
- Screenshot: https://shadcn.exchange/shot/cnippet/c-gauge-chart-2/light.png
- Registry item: https://ui.cnippet.dev/r/c-gauge-chart-2.json
- Categories: gauge chart
- Listed: 2026-10-27, source last changed 2026-10-27

## Install

```bash
npx shadcn@latest add https://shadcn.exchange/r/cnippet/c-gauge-chart-2.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@cnippet/gauge-chart`

## Files

### `registry/default/chart-variants/c-gauge-chart-2.tsx`

```tsx
"use client";

import { GaugeChart } from "@/registry/default/charts/gauge-chart";

const hosts = [
  { cpu: 38, name: "web-1" },
  { cpu: 71, name: "web-2" },
  { cpu: 93, name: "worker-1" },
];

// Same thresholds as the alerting rules: amber from 70%, red from 90%.
function loadColor(cpu: number) {
  if (cpu >= 90) return "var(--destructive)";
  if (cpu >= 70) return "var(--warning)";
  return "var(--success)";
}

export default function CpuLoad() {
  return (
    <div className="grid w-full max-w-lg grid-cols-3 gap-3">
      {hosts.map((h) => (
        <div className="rounded-lg border bg-card p-4" key={h.name}>
          <GaugeChart
            aria-label={`${h.name} CPU load`}
            color={loadColor(h.cpu)}
            label={h.name}
            value={h.cpu}
            valueFormatter={(value) => `${value}%`}
          />
        </div>
      ))}
    </div>
  );
}
```
