> ## Documentation Index
> Fetch the complete documentation index at: https://docs.graphy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Funnel

export const GraphPreview = ({config, aspectRatio = '10 / 6'}) => {
  const getThemeId = () => {
    return document.documentElement.classList.contains('dark') ? 'dark' : 'light';
  };
  const [themeId, setThemeId] = useState(getThemeId);
  const [isLoaded, setIsLoaded] = useState(false);
  config.appearance = {
    ...config.appearance,
    border: {
      style: 'none',
      color: 'transparent',
      width: 0
    },
    hasRoundedBorders: false
  };
  const baseUrl = window.location.hostname === 'localhost' ? 'https://app.graphy.top:8080' : 'https://visualize.graphy.app';
  const url = new URL('view/graph', baseUrl);
  url.searchParams.set('config', JSON.stringify(config));
  url.searchParams.set('themeId', themeId);
  useEffect(() => {
    const observer = new MutationObserver(function (mutations) {
      setThemeId(getThemeId());
    });
    observer.observe(document.documentElement, {
      attributes: true,
      attributeOldValue: true,
      attributeFilter: ['class']
    });
    return () => observer.disconnect();
  }, []);
  return <div className="graph-preview" style={{
    aspectRatio,
    opacity: isLoaded ? 1 : 0
  }}>
      <iframe src={url.toString()} loading="lazy" onLoad={() => setIsLoaded(true)} allowfullscreen="true" />
    </div>;
};

Funnel charts display progressively decreasing values across stages, ideal for visualising conversion processes and multi-stage workflows.

## When to use

* **Conversion funnels** - Track user journey from awareness to conversion
* **Process stages** - Show drop-off at each step
* **Progressive reduction** - Display sequential filtering or narrowing

## Basic example

<GraphPreview
  config={{
type: 'funnel',
data: {
  columns: [
    { key: 'stage', label: 'Stage' },
    { key: 'users', label: 'Users' },
  ],
  rows: [
    { stage: 'Website visits', users: 10000 },
    { stage: 'Product views', users: 5000 },
    { stage: 'Add to cart', users: 2000 },
    { stage: 'Checkout', users: 800 },
    { stage: 'Purchase', users: 500 },
  ],
},
}}
/>

```tsx theme={null}
const config: GraphConfig = {
  type: 'funnel',
  data: {
    columns: [
      { key: 'stage', label: 'Stage' },
      { key: 'users', label: 'Users' },
    ],
    rows: [
      { stage: 'Website visits', users: 10000 },
      { stage: 'Product views', users: 5000 },
      { stage: 'Add to cart', users: 2000 },
      { stage: 'Checkout', users: 800 },
      { stage: 'Purchase', users: 500 },
    ],
  },
};
```

## Conversion rate

Show the conversion rate between the first and last stages as a headline number:

```tsx theme={null}
const config: GraphConfig = {
  type: 'funnel',
  headlineNumbers: {
    show: 'conversion',
  },
  data: {
    /* ... */
  },
};
```

<Note>
  The `'conversion'` headline number type is specifically designed for funnel charts. It calculates the ratio between
  the first and last values.
</Note>

## Stage data

The funnel automatically calculates drop-off between stages. Your data should include:

* **First column**: Stage names (categorical)
* **Second column**: Values (numeric), ordered from highest to lowest

## Related

* [Headline numbers](/sdk/config/headline-numbers) - Show conversion rate
* [Data labels](/sdk/config/data-labels) - Display stage values
