Published
Edited
Aug 21, 2020
1 fork
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
data = d3.csvParse(await FileAttachment("cabinet2020@9.csv").text(), ({id, value, image, minister}) => ({
name: id.split(".").pop(),
title: id.replace(/\./g, "/"),
group: id.split(".")[0],
value: (value) ? Math.max(40, value): 0,
image: image,
minister: (minister.split(' ')[0] + ' ' + minister.split(' ').slice(-1)[0].toUpperCase()),
}))
Insert cell
pack = data => d3.pack()
.size([width - 2, height - 2])
.padding(3)
(d3.hierarchy({children: data})
.sum(d => d.value))
Insert cell
width = 932
Insert cell
height = width
Insert cell
format = d3.format(",d")
Insert cell
Insert cell
d3 = require("d3@5")
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