Published
Edited
Aug 31, 2021
4 stars
Insert cell
Insert cell
{
const context = DOM.context2d(width, height),
path = d3.geoPath().context(context);
context.translate(10, 10);

for (const c of contour) {
context.beginPath();
path(c);
context.fillStyle = color(c.value);
context.fill();
}

context.beginPath();
delaunay.render(context);
context.lineWidth = 0.25;
context.stroke();

return context.canvas;
}
Insert cell
points = d3
.hexbin()
.size([width - 20, height - 20])
.radius(20)
.centers()
.filter(d => Math.random() < 0.9)
Insert cell
delaunay = d3.Delaunay.from(points)
Insert cell
contour = d3.tricontour().value(d => Math.random())(points)
Insert cell
color = d3.scaleSequential(d3.interpolateBlues)
Insert cell
height = 500
Insert cell
d3 = require("d3@7", "d3-delaunay@6", "d3-hexbin@0.2", "d3-tricontour@1")
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