Gradient legend

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
Tier
Free Core
Collection
Heatmap
Render
Live, site theme
View .md Agent setup
LIVE/heatmap/gradient-legend4 of 10 in Heatmap

Configuration

Raw Standalone
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)
chart.render()