chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.attr("class", "color-cool-gray-3");
svg.append("g")
.style("font-size", "1rem")
.call(xAxis)
.append("text")
.attr("x", width / 2)
.attr("y", 40)
.attr("class", "xsmall-copy")
.attr("fill", "currentColor")
.attr("text-anchor", "middle")
.text(xLabel);
svg.append("g")
.selectAll("g")
.data(data)
.join("g")
.attr("transform", d => `translate(${x0(d[groupKey])},0)`)
.attr("data-index", (d, i) => i)
.selectAll("rect")
.data(d => keys.map(key => ({key, value: d[key]})))
.join("g")
.call(bars);
svg.select("g[data-index='0']")
.call(units);
return svg.node();
}