Published
Edited
May 28, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
__data = FileAttachment("flare-2.json").json()
Insert cell
data = d3.csvParse(await FileAttachment("AN_sales_data_small.csv").text(), d3.autoType)
Insert cell
partition = data => {
// const root = d3.hierarchy(data)
// .sum(d => d.value)
// .sort((a, b) => b.value - a.value);
const root = (stratify(data)
.sum(d => d.value)
.sort((a, b) => b.value - a.value))
return d3.partition()
.size([2 * Math.PI, root.height + 1])
(root);
}
Insert cell
stratify = d3.stratify()
.id(d => d.id)
.parentId(d => d.id.substring(0, d.id.lastIndexOf("@")))
Insert cell
__partition = data => {
const root = d3.hierarchy(data)
.sum(d => d.value)
.sort((a, b) => b.value - a.value);
return d3.partition()
.size([2 * Math.PI, root.height + 1])
(root);
}
Insert cell
color = d3.scaleOrdinal(d3.quantize(d3.interpolateRainbow, 18))
Insert cell
format = d3.format(",d")
Insert cell
width = 800
Insert cell
radius = width / 7
Insert cell
arc = d3.arc()
.startAngle(d => d.x0)
.endAngle(d => d.x1)
.padAngle(d => Math.min((d.x1 - d.x0) / 2, 0.005))
.padRadius(radius * 1.5)
.innerRadius(d => d.y0 * radius)
.outerRadius(d => Math.max(d.y0 * radius, d.y1 * radius - 1))
Insert cell
d3 = require("d3@6")
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