chart = {
const svg = d3.select(DOM.svg(width, height));
svg.append("g")
.selectAll("g")
.data(data)
.join("g")
.attr("transform", d => `translate(${x0(d[groupKey])},0)`)
.selectAll("rect")
.data(d => {
let allVals = [];
let desiredKeys = keys
desiredKeys.forEach((dKey) => {
let val = {
key: dKey,
value: d[dKey]
}
allVals.push(val);
})
return allVals;
})
.join("rect")
.attr("x", d => x1(d.key))
.attr("y", d => y(d.value))
.attr("width", x1.bandwidth())
.attr("height", d => y(0) - y(d.value))
.attr("fill", d => color(d.key));
svg.append("g")
.call(xAxis);
svg.append("g")
.call(legend);
return svg.node();
}