# C series toggle chart 1

> Visitors — desktop and mobile tabs with totals

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-series-toggle-chart-1).

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

## Install

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

## Files

### `registry/default/chart-variants/c-series-toggle-chart-1.tsx`

```tsx
"use client";

import { ChartCard } from "@/registry/default/charts/chart-card";
import { SeriesToggleChart } from "@/registry/default/charts/series-toggle-chart";
import { formatDate } from "@/registry/default/lib/chart-utils";

// 30 days of visitors by device.
const data = Array.from({ length: 30 }, (_, i) => {
  const date = new Date(Date.UTC(2026, 8, 26 + i));
  return {
    date: date.toISOString().slice(0, 10),
    desktop: Math.round(2400 + 22 * i + 520 * Math.sin(i / 3)),
    mobile: Math.round(1900 + 31 * i + 410 * Math.cos(i / 4)),
  };
});

export default function VisitorsByDevice() {
  return (
    <ChartCard className="max-w-2xl" title="Visitors, last 30 days">
      <SeriesToggleChart
        categories={["desktop", "mobile"]}
        className="h-40"
        data={data}
        index="date"
        indexFormatter={(value) => formatDate(value)}
      />
    </ChartCard>
  );
}
```
