chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
svg
.append("g")
.attr("fill", "#7c4ea5")
.selectAll("rect")
.data(data)
.join("rect")
.attr("x", (d) => x(d.value) - 0.75)
.attr("y", (d) => y(d.age))
.attr("width", 1)
.attr("height", y.bandwidth())
.append("title")
.text(
(d) => `${d.name}
${(d.value * 100).toFixed(1)}% ${d.age}`
);
return svg.node();
}