{
const svg = d3.create("svg")
.attr("width", width)
.attr("height", y.range()[1])
.attr("font-family", "sans-serif")
.attr("font-size", "10")
.attr("text-anchor", "end");
const bar = svg.selectAll("g")
.data(data)
.join("g")
.attr("transform", d => `translate(0,${y(d.name)})`);
bar.append("rect")
.attr("fill", "steelblue")
.attr("width", d => x(d.value))
.attr("height", y.bandwidth() - 1);
bar.append("text")
.attr("fill", "white")
.attr("x", d => x(d.value) - 3)
.attr("y", (y.bandwidth() - 1) / 2)
.attr("dy", "0.35em")
.text(d => d.value);
return svg.node();
}