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
Open the chart without page chrome ↗
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()import WestCoastCharts from 'west-coast-charts'
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() Waiting for the chart.
Open Data & agent view to read this chart through chart.describe().
Read from the running library through its optional agent/describe module. Text, table and JSON share the same snapshot. Demo data only.
$ wcc chart export heatmap-gradient-legend.json --out heatmap-gradient-legend.svg --with-table Public agent tools 0.2.3, tested with Library 1.1.5; available from the versioned GitHub release and npm. Save a JSON spec first and check the loaded runtime and supported modules before rendering. Command reference
Loading /gallery/heatmap/gradient-legend/index.md …