Published
Edited
Feb 12, 2021
1 star
Insert cell
md`# Interpolating Party Colors`
Insert cell
Insert cell
swatches(Object.values(COLORS))
Insert cell
ramp(d3.interpolateLab("#ffffff",COLORS.SPOE))
Insert cell
ramp(d3.interpolateRgb("#ffffff",COLORS.SPOE))
Insert cell
ramp(d3.interpolateHcl("#ffffff",COLORS.SPOE))
Insert cell
ramp(d3.interpolateLab("#ffffff",getColorScaleBaseColor(COLORS.SPOE)))
Insert cell
ramp(d3.interpolateRgb("#ffffff",getColorScaleBaseColor(COLORS.SPOE)))
Insert cell
ramp(d3.interpolateHcl("#ffffff",getColorScaleBaseColor(COLORS.SPOE)))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function getColorScaleBaseColor(color) {
let baseColor = d3.lab(color);
baseColor.l = baseLightness;
return baseColor;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function legend(colorScale) {
return swatches([0,0.2,0.4,0.6,0.8,1].map(colorScale))
}
Insert cell
d3 = require("d3@5")
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