# C box plot 2

> Latency by region — quartiles computed from raw samples

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-box-plot-2).

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

## Install

```bash
npx shadcn@latest add https://shadcn.exchange/r/cnippet/c-box-plot-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/box-plot`, `@cnippet/chart-card`

## Files

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

```tsx
"use client";

import { BoxPlot } from "@/registry/default/charts/box-plot";
import { ChartCard } from "@/registry/default/charts/chart-card";

// Raw request latencies per region (deterministic); the chart computes quartiles.
const regions = [
  ["us-east", 42],
  ["us-west", 58],
  ["eu-west", 71],
  ["ap-south", 128],
  ["sa-east", 154],
] as const;

const data = regions.map(([region, base], r) => ({
  latencies: Array.from(
    { length: 200 },
    (_, i) => base + ((i * (7 + r)) % 50) * (0.6 + r * 0.25),
  ),
  region,
}));

export default function LatencyByRegion() {
  return (
    <ChartCard
      className="max-w-2xl"
      description="Round-trip time to the API from each region, 200 samples each"
      footer="Quartiles are computed from the raw samples by the chart."
      title="Latency by region"
    >
      <BoxPlot
        className="h-40"
        color="var(--chart-2)"
        data={data}
        index="region"
        valueFormatter={(v) => `${Math.round(v)} ms`}
        values="latencies"
        yAxisWidth={56}
      />
    </ChartCard>
  );
}
```
