chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg
.selectAll("g")
.data(filteredBlossoms, (d) => d.year)
.join((enter) => {
const g = enter
.append("g")
.attr(
"transform",
(d) =>
`translate(${x(d.year)},${y(d.date)})scale(${petalScale(d.date)})`
);
g.selectAll("path")
.data((d) =>
_.times(d.numPetals, (i) =>
Object.assign({}, d, { rotate: i * (360 / d.numPetals) })
)
)
.join("path")
.attr("transform", (d) => `rotate(${d.rotate})scale(0.5)`)
.attr("fill", function (d) {
return color(d.date);
})
.attr("fill-opacity", 0.3)
.attr("d", (d) => d.path)
.attr("stroke-width", 10)
.attr("stroke", function (d) {
return color(d.date);
});
});
svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
svg.append("g").call(grid);
return svg.node();
}