# C realtime chart 3

> Price feed — a random walk

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-realtime-chart-3).

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

## Install

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

## Files

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

```tsx
"use client";

import { useRef } from "react";
import { ChartCard } from "@/registry/default/charts/chart-card";
import { RealtimeChart } from "@/registry/default/charts/realtime-chart";

export default function LivePrice() {
  // A random walk standing in for a price feed.
  const price = useRef(64250);

  return (
    <ChartCard className="max-w-2xl" title="BTC / USD">
      <RealtimeChart
        categories={["price"]}
        className="h-48"
        config={{ price: { color: "var(--chart-4)", label: "Price" } }}
        interval={800}
        onTick={() => {
          price.current *= 1 + (Math.random() - 0.495) * 0.002;
          return { price: Math.round(price.current) };
        }}
        valueFormatter={(value) =>
          `$${value.toLocaleString("en-US", { maximumFractionDigits: 0 })}`
        }
        windowSize={50}
        yAxisWidth={64}
      />
    </ChartCard>
  );
}
```
