# Gradient legend (Heatmap example)

> WestCoast Charts 1.1.5, release, public Core release, on npm. HTML: https://westcoast-charts.com/gallery/heatmap/gradient-legend/ · Index for agents: https://westcoast-charts.com/llms.txt

A continuous colour scale with a gradient legend bar.

Why it matters: continuous gradient legend with formatted end labels (WCC colorScale.gradientLegend); OKLab interpolation

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

## Setup

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

## Options

```js
const options = {
  chart: {
    height: 380,
    fontFamily: "Inter, Geist, \"IBM Plex Sans\", system-ui, sans-serif",
    type: "treemap",
    toolbar: {
      show: false
    }
  },
  series: [
    {
      name: "Revenue",
      data: [
        {
          x: "North",
          children: [
            {
              x: "Lisbon",
              y: 81,
              growth: -0.5
            },
            {
              x: "Oslo",
              y: 96,
              growth: 3.6
            },
            {
              x: "Seattle",
              y: 165,
              growth: -8.7
            },
            {
              x: "Osaka",
              y: 69,
              growth: 0.6
            }
          ]
        },
        {
          x: "South",
          children: [
            {
              x: "Austin",
              y: 75,
              growth: -7.4
            },
            {
              x: "Porto",
              y: 187,
              growth: 1.9
            },
            {
              x: "Tallinn",
              y: 198,
              growth: 3.2
            },
            {
              x: "Lyon",
              y: 78,
              growth: -4.1
            }
          ]
        },
        {
          x: "Islands",
          children: [
            {
              x: "Bergen",
              y: 39,
              growth: 3.6
            },
            {
              x: "Denver",
              y: 126,
              growth: 2.7
            },
            {
              x: "Kyoto",
              y: 191,
              growth: 0.6
            },
            {
              x: "Malmö",
              y: 111,
              growth: 2.3
            }
          ]
        }
      ]
    }
  ],
  plotOptions: {
    treemap: {
      colorScale: {
        colorValue: "growth",
        gradientLegend: {
          formatter: (v) => (v > 0 ? '+' : '') + v.toFixed(1) + '%'
        }
      }
    }
  },
  title: {
    text: "Stores by revenue, coloured by growth"
  },
  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 heatmap-gradient-legend.json --out heatmap-gradient-legend.svg --with-table` (save the options above as JSON first)
