Colour scale
Tiles coloured by change, red to green.
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: [
{
data: [
{
x: "Lisbon",
y: -3.5
},
{
x: "Oslo",
y: 2.1
},
{
x: "Seattle",
y: -0.8
},
{
x: "Osaka",
y: 1.3
},
{
x: "Austin",
y: 5
},
{
x: "Porto",
y: 4.5
},
{
x: "Tallinn",
y: 2.1
},
{
x: "Lyon",
y: -6.3
},
{
x: "Bergen",
y: 1
},
{
x: "Denver",
y: 0.4
},
{
x: "Kyoto",
y: -0.5
},
{
x: "Malmö",
y: 2
}
]
}
],
plotOptions: {
treemap: {
enableShades: false,
colorScale: {
ranges: [
{
from: -20,
to: 0,
color: "#e11d48"
},
{
from: 0.001,
to: 20,
color: "#0d9488"
}
]
}
}
},
dataLabels: {
formatter: (t, o) => [t, (o.value > 0 ? '+' : '') + o.value + '%']
},
title: {
text: "Weekly change by city"
},
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: [
{
data: [
{
x: "Lisbon",
y: -3.5
},
{
x: "Oslo",
y: 2.1
},
{
x: "Seattle",
y: -0.8
},
{
x: "Osaka",
y: 1.3
},
{
x: "Austin",
y: 5
},
{
x: "Porto",
y: 4.5
},
{
x: "Tallinn",
y: 2.1
},
{
x: "Lyon",
y: -6.3
},
{
x: "Bergen",
y: 1
},
{
x: "Denver",
y: 0.4
},
{
x: "Kyoto",
y: -0.5
},
{
x: "Malmö",
y: 2
}
]
}
],
plotOptions: {
treemap: {
enableShades: false,
colorScale: {
ranges: [
{
from: -20,
to: 0,
color: "#e11d48"
},
{
from: 0.001,
to: 20,
color: "#0d9488"
}
]
}
}
},
dataLabels: {
formatter: (t, o) => [t, (o.value > 0 ? '+' : '') + o.value + '%']
},
title: {
text: "Weekly change by city"
},
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 treemap-color-scale.json --out treemap-color-scale.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/treemap/color-scale/index.md …