# C spark bar 2

> Win/loss — last 15 games per team

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-bar-2).

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

## Install

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

## Files

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

```tsx
"use client";

import { SparkBar } from "@/registry/default/charts/spark-bar";

// Last 15 games per team: 1 = win, -1 = loss.
const teams = [
  {
    name: "Falcons",
    results: [1, 1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1],
  },
  {
    name: "Rovers",
    results: [-1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, -1],
  },
  {
    name: "Comets",
    results: [1, -1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1],
  },
];

export default function WinLoss() {
  return (
    <ul className="w-full max-w-sm divide-y rounded-lg border bg-card">
      {teams.map((t) => {
        const wins = t.results.filter((r) => r > 0).length;
        return (
          <li className="flex items-center gap-4 px-4 py-3" key={t.name}>
            <span className="flex-1 font-medium text-sm">{t.name}</span>
            <SparkBar
              aria-label={`${t.name}: ${wins} wins, ${t.results.length - wins} losses in the last 15 games`}
              categories={["result"]}
              className="h-8 w-36"
              colorBySign
              data={t.results.map((result, game) => ({ game, result }))}
              index="game"
            />
            <span className="w-10 text-end text-muted-foreground text-xs tabular-nums">
              {wins}–{t.results.length - wins}
            </span>
          </li>
        );
      })}
    </ul>
  );
}
```
