Public
Edited
May 1, 2023
1 fork
Insert cell
Insert cell
Insert cell
circles = d3.select(svgContainer).selectAll("circle")
.data(d3.range(10))
.join("circle")
.attr("cx", () => 50 + Math.random() * 500)
.attr("cy", () => 50 + Math.random() * 200)
.attr("r", "20")
.style("fill", d => d3.schemeCategory10[d])
.style("opacity", "0.8")
.call(drag)
Insert cell
drag = {

function dragstarted() {
d3.select(this).attr("stroke", "black");
}

function dragged(event, d) {
d3.select(this).raise().attr("cx", event.x).attr("cy", event.y);
}

function dragended() {
d3.select(this).attr("stroke", null);
}

return d3.drag()
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended);
}
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