Published unlisted
Edited
Jun 28, 2019
3 stars
Insert cell
Insert cell
compare(["black", "#9ad0ef", "white"])
Insert cell
compare(["black", "blue", "white"])
Insert cell
compare(["black", "red", "white"])
Insert cell
compare(["black", "yellow", "white"])
Insert cell
compare(["black", "green", "white"])
Insert cell
compare(["black", "violet", "white"])
Insert cell
compare(["black", "orange", "white"])
Insert cell
compare(["black", "magenta", "white"])
Insert cell
compare(["black", "cyan", "white"])
Insert cell
Insert cell
compare([d3.hcl(NaN, 0, 0), "blue", d3.hcl(NaN, 0, 100)])
Insert cell
d3.hcl("black")
Insert cell
d3.hcl("blue")
Insert cell
d3.hcl("yellow")
Insert cell
d3.hcl("white")
Insert cell
Insert cell
function compare(colors) {
return html`${[
ramp(d3.piecewise(d3.interpolateHcl, colors)),
ramp(d3.piecewise(d3.interpolateLab, colors))
]}`;
}
Insert cell
import {ramp} from "@mbostock/color-ramp"
Insert cell
d3 = require.alias({
"d3-color": "d3-color@1.2.8",
"d3-interpolate": "d3-interpolate@1.3.2"
})("d3-color", "d3-interpolate")
Insert cell
chroma = require("chroma-js")
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