# FunnelChart

> How many make it through each step of a flow, with the conversion from the previous step or from the start.

Status: beta. Category: Data display.

```ts
import { FunnelChart } from '@glyphui/ui/chart'
```

Exports: `FunnelChart`.

## Notes

- Rows are stages in order. Bar widths are relative to the first stage.
- One measure, one color: later stages are tints of the same hue.

## FunnelChart props

| Prop | Type | Default | Description |
|---|---|---|---|
| `category` (required) | `string` |  | Field naming each stage, e.g. `"stage"`. |
| `data` (required) | `readonly T[]` |  | One row per stage, in order. |
| `title` (required) | `string` |  |  |
| `value` (required) | `string` |  | Field holding how many reached the stage. |
| `className` | `string` |  |  |
| `color` | `ChartColorValue` |  | Default `chart-1`. Later stages are lighter tints of it. |
| `conversion` | `"none" \| "previous" \| "first"` |  | Under each value: share of the first stage or of the previous one. Default `previous`. |
| `description` | `ReactNode` |  |  |
| `empty` | `ReactNode` |  | Shown when there is no data. Defaults to a short "No data" message. |
| `error` | `unknown` |  | Shows an error message in place of the plot, with a retry button when `onRetry` is set. |
| `hideTitle` | `boolean` |  |  |
| `loading` | `boolean` |  | Shows a skeleton in place of the plot. |
| `onRetry` | `(() => unknown)` |  |  |
| `valueFormatter` | `((value: number) => string)` |  |  |

## Example: Signup funnel

Step-to-step conversion.

```tsx
import { FunnelChart } from '@glyphui/ui/chart'

const stages = [
  { stage: 'Visited pricing', people: 18420 },
  { stage: 'Started signup', people: 6210 },
  { stage: 'Verified email', people: 4870 },
  { stage: 'Created invoice', people: 2310 },
  { stage: 'Paid', people: 940 },
]

export default function Example() {
  return (
    <FunnelChart
      className="w-full"
      title="Signup to paid"
      description="Last 30 days"
      data={stages}
      category="stage"
      value="people"
    />
  )
}
```

## Example: Share of the first step

conversion="first" measures every step against the top of the funnel.

```tsx
import { FunnelChart } from '@glyphui/ui/chart'

const steps = [
  { step: 'Opened checkout', sessions: 3200 },
  { step: 'Entered card', sessions: 2140 },
  { step: 'Confirmed', sessions: 1890 },
]

export default function Example() {
  return (
    <FunnelChart
      className="w-full"
      title="Checkout completion"
      data={steps}
      category="step"
      value="sessions"
      conversion="first"
      color="chart-2"
    />
  )
}
```

Live page: https://glyphui.xyz/components/funnel-chart
