Public
Edited
Mar 4
1 fork
Insert cell
Insert cell
{
const data = [1, 3];
const size = 1024;
const r = size / 2;

const pie = (a, b) => d3.pie().sort(d3.ascending).startAngle(a).endAngle(b);

const arc = (a, b) =>
d3
.arc()
.innerRadius(r * a)
.outerRadius(r * b);

const pieOuter = pie(Math.PI / 4, Math.PI * 2 + Math.PI / 4);
const pieInner = pie((Math.PI / 4) * 5, Math.PI * 2 + (Math.PI / 4) * 5);

const dataOuter = pieOuter(data);
const dataInner = pieInner(data);

const arcOuter = arc(0.67, 1);
const arcMiddle = arc(0.33, 0.67);
const arcInner = arc(0, 0.34);

const app = cm.render({
width: size,
height: size,
viewBox: [-r, -r, size, size],
draw: [
SVG.path({ d: arcOuter(dataOuter[1]), fill: "#00ADB5" }),
SVG.path({ d: arcMiddle(dataOuter[1]), fill: "#393E46" }),
SVG.path({ d: arcInner(dataInner[0]), fill: "#393E46" })
]
});

return app.node();
}
Insert cell
SVG = cm.SVG;
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more