Public
Edited
Oct 24, 2023
5 stars
Insert cell
Insert cell
{
const interpolator = d3.interpolate("0, 51", "49 — 100");
return d3.quantize(interpolator, 8);
}
Insert cell
Insert cell
colorInterpolator = d3.interpolate("red", "blue")
Insert cell
d3.quantize(colorInterpolator, 2)
Insert cell
Insert cell
d3.quantize(d3.interpolateRound(0, 1e3), 10)
Insert cell
d3.quantize(colorInterpolator, 10)
Insert cell
Insert cell
qz = d3.scaleQuantize()
.domain([0, 1000])
.range(d3.quantize(colorInterpolator, 3))
Insert cell
Insert cell
qz(334)
Insert cell
Insert cell
dateInterpolator = d3.interpolateDate(new Date("2001-01"), new Date("2019-07"))
Insert cell
d3.quantize(dateInterpolator, 6) // 🕷 the same Date object is returned 6 times
Insert cell
d3.quantize(t => new Date(dateInterpolator(t)), 6) // 👍 a copy was made for each value
Insert cell
arrayInterpolator = d3.interpolate([0, 0], [1, 100])
Insert cell
d3.quantize(arrayInterpolator, 6) // 🕷 the same array is returned 6 times
Insert cell
d3.quantize(t => Array.from(arrayInterpolator(t)), 6) // 👍 a copy was made for each value
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more