Published
Edited
May 1, 2021
Insert cell
Insert cell
Insert cell
Insert cell
canvas = {
const context = DOM.context2d(width, height);
context.fillStyle = "#ffffff";
context.clearRect(0, 0, width, height);

context.canvas.id = "main-canvas";

return context.canvas;
}
Insert cell
Insert cell
d3.select("#main-canvas").on("click", e => {
const [x, y] = d3.pointer(e);
addBall({ x, y });
})
Insert cell
Insert cell
init = {
const tick = () => {
requestAnimationFrame(tick);

simulation.clearCanvas();
simulation.tick();
};

tick();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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