Published
Edited
Sep 16, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
chart = {
const svg = d3.select(DOM.svg(width, height));

const g = svg
.append("g")
.attr("transform", `translate(${width / 2},${height / 2})`);

g.selectAll("path")
.data(arcs)
.join("path")
.attr("fill", d => (d.data.arc === "hasColor" ? "blue" : 'none'))
.attr("stroke", 'blue')
.attr("stroke-width", "1px")
.attr("d", d => arc(d));

return svg.node();
}
Insert cell
Insert cell
arc = {
return d3
.arc()
.innerRadius(0)
.outerRadius(250);
}
Insert cell
pie = d3
.pie()
.sort(null)
.value(d => d.value)
Insert cell
data = [
{ arc: 'hasColor', value: progress },
{ arc: 'noColor', value: 100 - progress }
]
Insert cell
arcs = pie(data)
Insert cell
height = width
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