# C histogram 3

> Test scores — 20 narrow bands without a grid

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-histogram-3).

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

## Install

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

## Files

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

```tsx
"use client";

import { ChartCard } from "@/registry/default/charts/chart-card";
import { Histogram } from "@/registry/default/charts/histogram";

// Deterministic exam scores, roughly bell-shaped around 72.
const scores = Array.from({ length: 240 }, (_, i) => {
  const a = ((i * 13) % 17) / 17;
  const b = ((i * 29) % 23) / 23;
  return Math.round(45 + 27 * (a + b));
});

const passed = scores.filter((s) => s >= 60).length;

export default function TestScores() {
  return (
    <ChartCard
      className="max-w-2xl"
      description="Final exam, 240 students, 20 score bands"
      footer={`${passed} of ${scores.length} students scored 60 or more.`}
      title="Test scores"
    >
      <Histogram
        bins={20}
        className="h-48"
        color="var(--chart-3)"
        label="Students"
        showGrid={false}
        valueFormatter={(v) => String(Math.round(v))}
        values={scores}
      />
    </ChartCard>
  );
}
```
