Published
Edited
Sep 16, 2022
Importers
1 star
Insert cell
Insert cell
path = semicircle()
.cx(d => d.cx)
.cy(d => d.cy)
.r(d => d.r);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
path({cx, cy, r})
Insert cell
function semicircle(){
let cx = 0,
cy = 0,
r = 0;

function draw(datum){
const cx0 = typeof cx === "function" ? cx(datum) : cx,
cy0 = typeof cy === "function" ? cy(datum) : cy,
r0 = typeof r === "function" ? r(datum) : r;
return `M${cx0 - r0},${cy0} a1,1 0 1,1 ${r0 * 2},0`;
}

draw.cx = function(_){
return arguments.length ? (cx = _, draw) : cx
};
draw.cy = function(_){
return arguments.length ? (cy = _, draw) : cy;
}
draw.r = function(_){
return arguments.length ? (r = _, draw) : r;
}

return draw;
}
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