Published
Edited
Mar 12, 2018
3 stars
Insert cell
Insert cell
size = 300
Insert cell
mutable mousePos = ({x: size / 2, y: size / 2})
Insert cell
canvas = {
var c;
if (this) {
c = this.getContext('2d');
} else {
c = DOM.context2d(size, size);
c.fillStyle = "blue";
c.canvas.onmousemove = (e) => {
mutable mousePos = {x: e.offsetX, y: e.offsetY};
}
}
c.clearRect(0, 0, size, size);
c.beginPath();
c.arc(mousePos.x, mousePos.y, 10, 0, 2 * Math.PI);
c.fill();
return c.canvas;
}
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