# Funnel chart

A conversion funnel that says where people stop: one smooth shape that narrows step by step, the drop on a chip at every seam, the biggest drop called out and last period as a ghost.

Also called: conversion funnel.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Funnel chart. From pricing page to paid, this week against last: connecting a source is where most people stop. Preview: https://chatcn.dev/preview/funnel-chart-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/funnel-chart
```

## Usage

```tsx
import { FunnelChart } from "@/components/ui/chatcn/pro/funnel-chart"

<FunnelChart
  title="Activation, this week"
  unit="people"
  steps={[
    { label: "Started sign up", value: 9640, previous: 8570 },
    { label: "Verified email", value: 7230, previous: 6600 },
    { label: "Connected a source", value: 3180, previous: 3170 },
  ]}
/>

<FunnelChart variant="bars" steps={steps} />     // a rounded bar per step with ribbons
<FunnelChart variant="compact" steps={steps} />  // a short strip for a dashboard card
```

By default the steps form one centered shape: a flat band per step, as wide as its share of the first, with an S curve narrowing into the next and a hairline seam between them. The gradient fades down the funnel. The drop between two steps sits on a chip at their seam, and the biggest drop turns red with a falling arrow and its name, so the place to work on is obvious; a step that grows reads plus. The headline is the share that makes it through, and with `previous` its change on last period in points, while last period is drawn as a dashed ghost outline around the shape. Point at a step and it saturates while the rest step back, with a tooltip card of its count, share, drop and last period. `variant="bars"` draws a rounded bar per step with a conversion ribbon to the next and dashed last period bars; `variant="compact"` lays the shape out left to right in about 100 px for a card, with the label and share under each step. On phones the labels take half the width and shorten with an ellipsis. Arrow keys walk the steps, and the table button shows every step with its drop.

## Examples

### States

Example: States. Three steps without a comparison, loading, and a failed load. Preview: https://chatcn.dev/preview/funnel-chart-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `steps` | `FunnelStep[]` | `{ label, value, previous? }`, first step first |
| `variant` | `"bands" | "bars" | "compact"` | Default `bands`, one tapered shape. `bars` has ribbons, `compact` is a card strip |
| `headline` | `ReactNode` | Default: the share that makes it through and its change in points. `null` hides it |
| `unit`, `valueFormat` |  | How counts read |
| `title`, `description` | `ReactNode` | The caption |
| `loading`, `error`, `onRetry` |  |  |
| `labels` | `Partial<FunnelChartLabels>` | Every string, for translation |

## Keyboard

| Key | Action |
| --- | --- |
| Tab | Focus the chart; the first step is read out |
| Arrow keys | Next or previous step |
| Home, End | First or last step |

## Accessibility

- The chart is summarized in words with the overall rate and the biggest drop, with a table of every step.
- Drops are numbers on chips, not only shapes; the biggest drop carries an arrow and its name as well as red.
- The readout says the pointed or focused step in words: count, share, drop and change on last period.

## Motion

The shape grows out from its center, and bars from the start, once over 760 ms; chips and the ghost fade in with it. Pointing fades the other steps over 200 ms. Under reduced motion it appears drawn.

Source: https://chatcn.dev/docs/components/funnel-chart