Published
Edited
May 8, 2019
1 fork
22 stars
Insert cell
Insert cell
{
const w = Math.min(width, 600),
context = (this && this.getContext("2d")) || DOM.context2d(width, w);

const step = (Math.PI * (-10 + ((now / 1000) % 20))) / 20;

const spiral = Array.from({ length: w / 6 }, (_, i) => [
step * i,
w / 2 - 3 * i
]);

context.fillStyle = "rgba(255,255,255,0.1)";
context.fillRect(0, 0, width, w);

context.save();
context.translate(width / 2, w / 2);

context.beginPath();
d3
.lineRadial()
.context(context)
.curve(d3.curveNatural)(spiral);
context.stroke();

context.restore(); // undo translate

yield context.canvas;
}
Insert cell
d3 = require("d3-shape@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