> ## 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.

# Stacked area

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>;
};

Stacked area charts display multiple series as filled areas stacked on top of each other, showing both individual series values and the cumulative total.

## When to use

* **Part-to-whole over time** - Show how components contribute to a total
* **Cumulative values** - Display running totals
* **Multiple series composition** - Compare proportions across time periods

## Basic example

<GraphPreview
  config={{
type: 'areaStacked',
data: {
  columns: [
    { key: 'quarter', label: 'Quarter' },
    { key: 'product_a', label: 'Product A' },
    { key: 'product_b', label: 'Product B' },
    { key: 'product_c', label: 'Product C' },
  ],
  rows: [
    { quarter: 'Q1', product_a: 30, product_b: 20, product_c: 15 },
    { quarter: 'Q2', product_a: 35, product_b: 25, product_c: 20 },
    { quarter: 'Q3', product_a: 40, product_b: 30, product_c: 25 },
    { quarter: 'Q4', product_a: 45, product_b: 35, product_c: 30 },
  ],
},
}}
/>

```tsx theme={null}
const config: GraphConfig = {
  type: 'areaStacked',
  data: {
    columns: [
      { key: 'quarter', label: 'Quarter' },
      { key: 'product_a', label: 'Product A' },
      { key: 'product_b', label: 'Product B' },
      { key: 'product_c', label: 'Product C' },
    ],
    rows: [
      { quarter: 'Q1', product_a: 30, product_b: 20, product_c: 15 },
      { quarter: 'Q2', product_a: 35, product_b: 25, product_c: 20 },
      { quarter: 'Q3', product_a: 40, product_b: 30, product_c: 25 },
      { quarter: 'Q4', product_a: 45, product_b: 35, product_c: 30 },
    ],
  },
};
```

## Related

* [Type options](/sdk/config/type-options) - Line chart options also apply
* [Legend](/sdk/config/legend) - Show series labels
* [Data labels](/sdk/config/data-labels) - Display values on areas
