chart = {
const svg = d3.create("svg")
.attr("viewBox", [-10, 0, width, height]);
svg.append("g")
.selectAll("rect")
.data(data)
.join("rect")
.attr("x", x(0))
.attr("y", (d, i) => y(i))
.attr("width", d => x(d.value) - x(0))
.attr("height", y.bandwidth())
.attr("fill", d => color(d.name));
svg.append("g")
.attr("fill", "white")
.attr("text-anchor", "end")
.attr("font-family", "sans-serif")
.attr("font-size", 20)
.selectAll("text")
.data(data)
.join("text")
.attr("x", d => x(d.value) - 4)
.attr("y", (d, i) => y(i) + y.bandwidth() / 2)
.attr("margin.right","0.3em")
.attr("dy", "0.25em")
.attr("dx", "0.1em")
.text(d => format(d.value));
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis)
.attr("font-size", 30);
return svg.node();
}