chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
const group = svg.append("g");
let rect = group.selectAll("rect");
return Object.assign(svg.node(), {
draw() {
const t = svg.transition()
.ease(d3.easeLinear)
.duration(delay);
rect = rect
.data(data.filter(d => d.year === 2005))
.join(
enter => enter.append("rect")
.style("mix-blend-mode", "darken")
.attr("fill", d => color(d.sex))
.attr("x", d => x(d.age))
.attr("y", d => y(d.value))
.attr("width", x.bandwidth() + 1)
.attr("height", d => y(0) - y(d.value))
);
}
});
}