{
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg
.append("g")
.attr("id", "comets")
.selectAll("path")
.data([aggregate].concat(data))
.join("path")
.style("opacity", (_, i) => (!i ? 1 : .5))
.attr("d", comet())
.attr("fill", (d, i) =>
!i ? "#000" : color(Math.log(d.endweight / d.startweight))
)
.append("title")
.text(d => `${d.state} - ${d.birthweight}`);
const axes = svg.append("g");
axes
.append("g")
.attr("transform", `translate(0, ${y.range()[0]})`)
.call(d3.axisBottom(x).tickFormat(tickFormat))
.append("text")
.attr("transform", `translate(${x.range()[1] + 20}, 0)`)
.style("fill", "black")
.text("weight");
axes
.append("g")
.attr("transform", `translate(${x.range()[0]}, 0)`)
.call(d3.axisLeft(y).tickFormat(tickFormat))
.append("text")
.attr("transform", `translate(0, ${y.range()[1] - 15})`)
.style("fill", "black")
.text("value");
return svg.node();
}