Public
Edited
Apr 19, 2024
Insert cell
Insert cell
Plot.plot({
width: 450,
projection: {
type: "azimuthal-equidistant",
rotate: [0, -90],
// Adjust the domain for the maximum value of the scale (5) with a bit of margin for labels
domain: d3.geoCircle().center([0, 90]).radius(5 + 1.7)()
},
color: { legend: true },
marks: [
// grey discs representing each step on the scale from 1 to 5
Plot.geo([5, 4, 3, 2, 1], {
geometry: (r) => d3.geoCircle().center([0, 90]).radius(r)(),
stroke: "black",
fill: "black",
strokeOpacity: 0.3,
fillOpacity: 0.03,
strokeWidth: 0.5
}),

// white axes
Plot.link(longitude.domain(), {
x1: longitude,
y1: 90 - 5.5, // This sets the axis lines to extend beyond the 5 scale mark
x2: 0,
y2: 90,
stroke: "white",
strokeOpacity: 0.5,
strokeWidth: 2.5
}),

// tick labels representing each step on the scale from 1 to 5
Plot.text([1, 2, 3, 4, 5], {
x: 160,
y: (d) => 90 - d, // Place the label at the appropriate distance
dx: 2,
textAnchor: "start",
text: (d) => d.toString(),
fill: "currentColor",
stroke: "white",
fontSize: 10
}),

// axes labels
Plot.text(longitude.domain(), {
x: longitude,
y: 90 - 6, // Position the labels outside the outermost circle
text: Plot.identity,
lineWidth: 5
}),

// areas and points should use the actual values instead of scaled percentages
Plot.area(points, {
x1: ({ key }) => longitude(key),
y1: ({ value }) => 90 - value,
x2: 0,
y2: 90,
fill: "name",
stroke: "name",
curve: "cardinal-closed"
}),
Plot.dot(points, {
x: ({ key }) => longitude(key),
y: ({ value }) => 90 - value,
fill: "name",
stroke: "white"
}),
Plot.text(
points,
Plot.pointer({
x: ({ key }) => longitude(key),
y: ({ value }) => 90 - value, // Use the actual value for label positioning
text: (d) => d.value.toString(),
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
suppliers@3.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
suppliers = FileAttachment("suppliers@3.csv").csv({typed: true})
Insert cell
Insert cell
points = suppliers.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

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