Public
Edited
Jun 3, 2023
1 fork
Insert cell
Insert cell
chart = {
const svg = d3
.create("svg")
.attr("viewBox", [-width / 2, -height / 2, width, height])
.attr("stroke-linejoin", "round")
.attr("stroke-linecap", "round");

svg
.append("path")
.attr("fill", "lightsteelblue")
.attr("fill-opacity", 0.2)
.attr(
"d",
area.innerRadius((d) => y(d.hsMin)).outerRadius((d) => y(d.maxMax))(data)
);

svg
.append("path")
.attr("fill", "steelblue")
.attr("fill-opacity", 0.2)
.attr(
"d",
area.innerRadius((d) => y(d.hsMin)).outerRadius((d) => y(d.hsMax))(data)
);

svg
.append("path")
.attr("fill", "none")
.attr("stroke", "steelblue")
.attr("stroke-width", 1.5)
.attr(
"d",
line.radius((d) => {
return y(d.hsMean);
})(data)
);

return svg.node();
}
Insert cell
(line.radius((d) => {
return y(d.hsMean);
})(data)).split("L").map(d => d.split(','))
Insert cell
viewof selectionYear = Inputs.range([2006, 2023], {value: 2022, step: 1, label: "Year"})
Insert cell
outerRadius = width / 2 - margin
Insert cell
innerRadius = width / 5
Insert cell
margin = 10
Insert cell
height = width
Insert cell
line = d3
.lineRadial()
.curve(d3.curveLinear)
.angle((d) => {
return x(d.dayOfYear);
})
Insert cell
y(1)
Insert cell
y = d3
.scaleLinear()
.domain([d3.min(data, (d) => d.hsMin), d3.max(data, (d) => d.maxMax)])
.range([innerRadius, outerRadius])
Insert cell
x = d3
.scaleLinear()
.domain([1, 366])
.range([0, 2 * Math.PI])
Insert cell
area = d3
.areaRadial()
.curve(d3.curveBasis)
.angle((d) => x(d.dayOfYear))
Insert cell
data = rawdata.filter(d => d.year === selectionYear)
Insert cell
rawdata = FileAttachment("dailySubset.json").json()
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