# Nested market map (Treemap example)

> WestCoast Charts 1.1.5, release, public Core release, on npm. HTML: https://westcoast-charts.com/gallery/treemap/nested-market-map/ · Index for agents: https://westcoast-charts.com/llms.txt

Sectors and companies sized by market cap, coloured by daily change, dark-friendly.

- Chart type: `treemap` (Treemap)
- Collection: Treemap · Treemap
- Raw configuration: https://westcoast-charts.com/gallery-src/treemap/nested-market-map.js
- Standalone example: https://westcoast-charts.com/embed/samples/wcc/gallery/treemap/nested-market-map.html

## Setup

```js
import WestCoastCharts from 'west-coast-charts'
```

## Options

```js
const options = {
  chart: {
    height: 460,
    fontFamily: "Inter, Geist, \"IBM Plex Sans\", system-ui, sans-serif",
    type: "treemap",
    toolbar: {
      show: false
    }
  },
  series: [
    {
      name: "Cap",
      data: [
        {
          x: "Technology",
          children: [
            {
              x: "Nimbus",
              y: 66,
              growth: -0.3
            },
            {
              x: "Quark",
              y: 74,
              growth: 0.2
            },
            {
              x: "Helix",
              y: 228,
              growth: 1.1
            },
            {
              x: "Arcade",
              y: 102,
              growth: -1.2
            },
            {
              x: "Lumen",
              y: 160,
              growth: -1.7
            }
          ]
        },
        {
          x: "Health",
          children: [
            {
              x: "Medica",
              y: 320,
              growth: 6.1
            },
            {
              x: "Vitae",
              y: 71,
              growth: -1.4
            },
            {
              x: "Pulse",
              y: 88,
              growth: -3.8
            }
          ]
        },
        {
          x: "Energy",
          children: [
            {
              x: "Volt",
              y: 155,
              growth: 4.3
            },
            {
              x: "Tidal",
              y: 177,
              growth: -0.6
            },
            {
              x: "Ember",
              y: 319,
              growth: -3
            }
          ]
        },
        {
          x: "Finance",
          children: [
            {
              x: "Ledger",
              y: 56,
              growth: -1.3
            },
            {
              x: "Vault",
              y: 206,
              growth: -0.8
            },
            {
              x: "Mint",
              y: 56,
              growth: -1.9
            },
            {
              x: "Harbor",
              y: 361,
              growth: 0.3
            }
          ]
        },
        {
          x: "Retail",
          children: [
            {
              x: "Basket",
              y: 252,
              growth: 2.2
            },
            {
              x: "Aisle",
              y: 217,
              growth: 0.2
            }
          ]
        }
      ]
    }
  ],
  plotOptions: {
    treemap: {
      colorScale: {
        colorValue: "growth",
        gradientLegend: {
          formatter: (v) => (v > 0 ? '+' : '') + v.toFixed(1) + '%'
        }
      },
      dataLabels: {
        showValue: false
      }
    }
  },
  title: {
    text: "Market map: size = cap, colour = daily change"
  },
  theme: {
    mode: "light",
    preset: "coastal"
  }
}

const chart = new WestCoastCharts(document.querySelector('#chart'), options)
await chart.render()
```

## Verify

- Text check (Library 1.1.5): load `west-coast-charts/agent/describe` and call `chart.describe({ format: "json" })` for the actual drawn state. The live reader is on this example’s HTML page.
- Command line (Public agent tools 0.2.3, tested with Library 1.1.5; available from the versioned GitHub release and npm, https://westcoast-charts.com/docs/cli/index.md): `wcc chart export treemap-nested-market-map.json --out treemap-nested-market-map.svg --with-table` (save the options above as JSON first)
