Published
Edited
Dec 10, 2019
Insert cell
md`# Special Scale`
Insert cell
{
console.log(d3, 'wow');
const scale = value => {
if (value === 0) return "#fff";
if (value < 0)
return d3
.scaleThreshold()
.domain([-100, -30, -10])
.range(["#fe466f", "#fe8da5", "#fdd3dc"])(value);
if (value > 0)
return d3
.scaleThreshold()
.domain([10, 30, 100])
.range(["#dbfdee", "#a7fbd0", "#72f9b2"])(value);
};

console.log(-1, scale(-1));
console.log(0, scale(0));
console.log(1, scale(1));
}
Insert cell
d3 = require('d3')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more