chart = {
const svg = d3.select(DOM.svg(width, height));
svg.append("g")
.selectAll("g")
.data(data)
.join("g")
.attr("transform", d => `translate(0,${y0(d[groupKey])})`)
.selectAll("rect")
.data(d => keys.map(key => ({key, value: d[key]})))
.join("rect")
.attr("x", d => x(0))
.attr("y", d => y1(d.key))
.attr("height", y1.bandwidth())
.attr("width", d => x(d.value) - x(0))
.attr("fill", d => color(d.key));
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
svg.append("g")
.call(legend);
return svg.node();
}