# Colour ranges (Heatmap example)

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

Named value ranges with their own colours, negatives included.

- Chart type: `heatmap` (Heatmap)
- Collection: Heatmap · Heatmap
- Raw configuration: https://westcoast-charts.com/gallery-src/heatmap/color-range.js
- Standalone example: https://westcoast-charts.com/embed/samples/wcc/gallery/heatmap/color-range.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: "heatmap",
    toolbar: {
      show: false
    }
  },
  series: [
    {
      name: "Atlas",
      data: [
        {
          x: "Jan",
          y: -4
        },
        {
          x: "Feb",
          y: 4
        },
        {
          x: "Mar",
          y: 4
        },
        {
          x: "Apr",
          y: 34
        },
        {
          x: "May",
          y: 51
        },
        {
          x: "Jun",
          y: -10
        },
        {
          x: "Jul",
          y: 5
        },
        {
          x: "Aug",
          y: 11
        },
        {
          x: "Sep",
          y: -3
        },
        {
          x: "Oct",
          y: -22
        },
        {
          x: "Nov",
          y: -17
        },
        {
          x: "Dec",
          y: -19
        }
      ]
    },
    {
      name: "Beacon",
      data: [
        {
          x: "Jan",
          y: -30
        },
        {
          x: "Feb",
          y: 52
        },
        {
          x: "Mar",
          y: 32
        },
        {
          x: "Apr",
          y: 16
        },
        {
          x: "May",
          y: 47
        },
        {
          x: "Jun",
          y: 58
        },
        {
          x: "Jul",
          y: 10
        },
        {
          x: "Aug",
          y: -1
        },
        {
          x: "Sep",
          y: 42
        },
        {
          x: "Oct",
          y: -3
        },
        {
          x: "Nov",
          y: -20
        },
        {
          x: "Dec",
          y: 59
        }
      ]
    },
    {
      name: "Cirrus",
      data: [
        {
          x: "Jan",
          y: -21
        },
        {
          x: "Feb",
          y: 59
        },
        {
          x: "Mar",
          y: 57
        },
        {
          x: "Apr",
          y: -17
        },
        {
          x: "May",
          y: -26
        },
        {
          x: "Jun",
          y: -10
        },
        {
          x: "Jul",
          y: 51
        },
        {
          x: "Aug",
          y: 42
        },
        {
          x: "Sep",
          y: -11
        },
        {
          x: "Oct",
          y: -4
        },
        {
          x: "Nov",
          y: -9
        },
        {
          x: "Dec",
          y: 60
        }
      ]
    },
    {
      name: "Delta",
      data: [
        {
          x: "Jan",
          y: -19
        },
        {
          x: "Feb",
          y: 36
        },
        {
          x: "Mar",
          y: 52
        },
        {
          x: "Apr",
          y: 11
        },
        {
          x: "May",
          y: -10
        },
        {
          x: "Jun",
          y: 29
        },
        {
          x: "Jul",
          y: -26
        },
        {
          x: "Aug",
          y: 9
        },
        {
          x: "Sep",
          y: 7
        },
        {
          x: "Oct",
          y: 36
        },
        {
          x: "Nov",
          y: 1
        },
        {
          x: "Dec",
          y: -25
        }
      ]
    },
    {
      name: "Ember",
      data: [
        {
          x: "Jan",
          y: -11
        },
        {
          x: "Feb",
          y: 31
        },
        {
          x: "Mar",
          y: 60
        },
        {
          x: "Apr",
          y: -28
        },
        {
          x: "May",
          y: 15
        },
        {
          x: "Jun",
          y: 34
        },
        {
          x: "Jul",
          y: -10
        },
        {
          x: "Aug",
          y: -19
        },
        {
          x: "Sep",
          y: 4
        },
        {
          x: "Oct",
          y: 50
        },
        {
          x: "Nov",
          y: 49
        },
        {
          x: "Dec",
          y: 50
        }
      ]
    },
    {
      name: "Fjord",
      data: [
        {
          x: "Jan",
          y: 38
        },
        {
          x: "Feb",
          y: -21
        },
        {
          x: "Mar",
          y: -8
        },
        {
          x: "Apr",
          y: 28
        },
        {
          x: "May",
          y: -23
        },
        {
          x: "Jun",
          y: 19
        },
        {
          x: "Jul",
          y: -16
        },
        {
          x: "Aug",
          y: 35
        },
        {
          x: "Sep",
          y: 40
        },
        {
          x: "Oct",
          y: -3
        },
        {
          x: "Nov",
          y: 18
        },
        {
          x: "Dec",
          y: 24
        }
      ]
    }
  ],
  plotOptions: {
    heatmap: {
      shadeIntensity: 0.4,
      colorScale: {
        ranges: [
          {
            from: -30,
            to: -0.1,
            name: "loss",
            color: "#e11d48"
          },
          {
            from: 0,
            to: 20,
            name: "flat",
            color: "#94a3b8"
          },
          {
            from: 20.1,
            to: 40,
            name: "growth",
            color: "#14b8a6"
          },
          {
            from: 40.1,
            to: 60,
            name: "strong",
            color: "#0f766e"
          }
        ]
      }
    }
  },
  dataLabels: {
    enabled: true
  },
  title: {
    text: "Monthly growth by product (%)"
  },
  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-color-range.json --out heatmap-color-range.svg --with-table` (save the options above as JSON first)
