# C spark area 3

> Trend colours — green or red by direction, inverted for errors and CPU

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-spark-area-3).

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

## Install

```bash
npx shadcn@latest add https://shadcn.exchange/r/cnippet/c-spark-area-3.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/spark-area`

## Files

### `registry/default/chart-variants/c-spark-area-3.tsx`

```tsx
"use client";

import { SparkArea } from "@/registry/default/charts/spark-area";

// Hourly values for the last 12 hours. Error rate falling is good news.
const metrics = [
  {
    data: [42, 44, 41, 47, 52, 55, 53, 58, 61, 64, 62, 68],
    invert: false,
    name: "Requests / s",
    value: "68",
  },
  {
    data: [2.1, 2.4, 2.2, 1.9, 1.7, 1.8, 1.4, 1.2, 1.1, 0.9, 0.8, 0.7],
    invert: true,
    name: "Error rate",
    value: "0.7%",
  },
  {
    data: [61, 58, 60, 63, 66, 70, 72, 71, 75, 78, 81, 84],
    invert: true,
    name: "CPU",
    value: "84%",
  },
];

export default function TrendColouredMetrics() {
  return (
    <div className="grid w-full max-w-md gap-3">
      {metrics.map((m) => (
        <div
          className="flex items-center justify-between gap-4 rounded-lg border bg-card px-4 py-3"
          key={m.name}
        >
          <div>
            <div className="text-muted-foreground text-xs">{m.name}</div>
            <div className="font-semibold text-lg tabular-nums">{m.value}</div>
          </div>
          <SparkArea
            aria-label={`${m.name} trend, last 12 hours`}
            categories={["v"]}
            className="h-10 w-32"
            colorByTrend
            data={m.data.map((v, hour) => ({ hour, v }))}
            index="hour"
            invertTrend={m.invert}
          />
        </div>
      ))}
    </div>
  );
}
```
