Public
Edited
Sep 8, 2023
Insert cell
Insert cell
Plot.plot({
width: 450,
projection: {
type: "azimuthal-equidistant",
rotate: [0, -90],
// Note: 1.250° corresponds to max. length (here, 0.5), plus enough room for the labels
domain: d3.geoCircle().center([0,90]).radius(1.250)()
},
color: { legend: true },
marks: [
// grey discs
Plot.geo([1.0,0.9,0.8,0.7,0.6,0.5, 0.4, 0.3, 0.2, 0.1], {
geometry: (r) => d3.geoCircle().center([0, 90]).radius(r)(),
stroke: "black",
fill: "black",
strokeOpacity: 0.1,
fillOpacity: 0.01,
strokeWidth: 0.2
}),
// white axes
Plot.link(longitude.domain(), {
x1: longitude,
y1: 90 - 0.90,
x2: 0,
y2: 90,
stroke: "white",
strokeOpacity: 0.5,
strokeWidth: 2.5
}),
// tick labels
Plot.text([0.25,0.5,0.75], {
x: 180,
y: (d) => 90 - d,
dx: 2,
textAnchor: "start",
text: (d) => `${100 * d}%`,
fill: "currentColor",
stroke: "white",
fontSize: 8
}),
// axes labels
Plot.text(longitude.domain(), {
x: longitude,
y: 90 - 1.0,
text: Plot.identity,
lineWidth: 5
}),
// areas
Plot.area(points, {
x1: ({ key }) => longitude(key),
y1: ({ value }) => 90 - value,
x2: 0,
y2: 90,
fill: "name",
stroke: "name",
curve: "cardinal-closed"
}),

// // points
// Plot.dot(points, {
// x: ({ key }) => longitude(key),
// y: ({ value }) => 90 - value,
// fill: "name",
// stroke: "white"
// }),

// interactive labels
Plot.text(
points,
Plot.pointer({
x: ({ key }) => longitude(key),
y: ({ value }) => 90 - value,
text: (d) => `${(100 * d.value).toFixed(0)}%`,
textAnchor: "start",
dx: 4,
fill: "currentColor",
stroke: "white",
maxRadius: 10
})
),

// interactive opacity on the areas
() =>
svg`<style>
g[aria-label=area] path {fill-opacity: 0.1; transition: fill-opacity .2s;}
g[aria-label=area]:hover path:not(:hover) {fill-opacity: 0.05; transition: fill-opacity .2s;}
g[aria-label=area] path:hover {fill-opacity: 0.3; transition: fill-opacity .2s;}
`
]
})
Insert cell
phones = FileAttachment("acquisition-tree-7.csv").csv({typed: true})
Insert cell
acquisition-tree-7.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
points = phones.flatMap(({ name, ...values }) =>
Object.entries(values).map(([key, value]) => ({ name, key, value }))
)
Insert cell
Insert cell
longitude = d3.scalePoint(new Set(Plot.valueof(points, "key")), [180, -180]).padding(0.5).align(1)
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