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

# Mekko

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

Mekko charts (also called marimekko or market map charts) display stacked bars with variable widths, showing both size and composition simultaneously.

## When to use

* **Market share analysis** - Show market size and segment composition
* **Portfolio breakdown** - Display size and composition of groups
* **Two-dimensional part-to-whole** - Compare both totals and proportions
* **Strategic positioning** - Visualise competitive landscape

## Basic example

<GraphPreview
  config={{
type: 'mekko',
data: {
  columns: [
    { key: 'region', label: 'Region' },
    { key: 'product_a', label: 'Product A' },
    { key: 'product_b', label: 'Product B' },
    { key: 'product_c', label: 'Product C' },
  ],
  rows: [
    { region: 'North America', product_a: 120, product_b: 80, product_c: 50 },
    { region: 'Europe', product_a: 90, product_b: 110, product_c: 40 },
    { region: 'Asia Pacific', product_a: 200, product_b: 150, product_c: 100 },
    { region: 'Latin America', product_a: 40, product_b: 30, product_c: 20 },
  ],
},
}}
/>

```tsx theme={null}
const config: GraphConfig = {
  type: 'mekko',
  data: {
    columns: [
      { key: 'region', label: 'Region' },
      { key: 'product_a', label: 'Product A' },
      { key: 'product_b', label: 'Product B' },
      { key: 'product_c', label: 'Product C' },
    ],
    rows: [
      { region: 'North America', product_a: 120, product_b: 80, product_c: 50 },
      { region: 'Europe', product_a: 90, product_b: 110, product_c: 40 },
      { region: 'Asia Pacific', product_a: 200, product_b: 150, product_c: 100 },
      { region: 'Latin America', product_a: 40, product_b: 30, product_c: 20 },
    ],
  },
};
```

## Data structure

Mekko charts require:

* **First column**: Categories (becomes variable-width bars)
* **Remaining columns**: Numeric values (stacked segments within each bar)

## Related

* [Bar](/sdk/graph-types/bar) - Fixed-width stacked bars
* [Column](/sdk/graph-types/column) - Percentage composition
