brush_chart = {
const svg_brush = d3.create("svg")
.attr("class", "show-up")
.attr("viewBox", [0, 0, width, brushHeight])
svg_brush.append("g")
.call(xAxisBrush);
svg_brush.append("g")
.attr("class", "hidden-date-axis")
.style("visibility", "hidden")
.call(d3.axisBottom(xDateAxis));
svg_brush.append("g")
.selectAll("g")
.data(data)
.enter()
.append("g")
.attr("class", "barGroup")
.attr("transform", function(d) { return "translate(" + x(d.group) + ",0)"; })
const monthlyAxes = getMonthlyAxes(svg_brush);
const xSubgroupMonths = d3.scaleBand()
.domain(subgroups)
.rangeRound([0, monthlyAxes[0].bandwidth()])
.padding([0.05]);
svg_brush.selectAll(".barGroup")
.append("g")
.attr("class", "barGroup-Secondary")
.selectAll("g")
.data((d) => { return dataMonth.filter(data => data.group === d.group) })
.enter()
.append("g")
.style("background-color", "pink")
.attr("transform", function(d, i) {
const xCoord = monthlyAxes
.find(x => x(`${d.group}-${d.groupSecondary}`) !== undefined)
(`${d.group}-${d.groupSecondary}`)
return "translate(" + xCoord + ",0)";
})
.selectAll("rect")
.data(d =>
subgroups
.filter(subgroup => !!d[subgroup])
.map(subgroup => ({key: subgroup, value: d[subgroup]}))
)
.enter().append("rect")
.attr("class", "bar")
.attr("fill", function(d) { return color(d.key); })
.attr("x", function(d) { return xSubgroupMonths(d.key); })
.attr("y", function(d) { return yBrush(d.value); })
.attr("width", xSubgroupMonths.bandwidth())
.exit().remove();
svg_brush.selectAll("rect")
.transition()
.duration(400)
.attr("y", d => yBrush(d.value))
.attr("height", function(d) { return yBrush(1) - yBrush(d.value); })
.delay(300)
d3.selectAll('.handle').remove();
d3.selectAll('.resize').remove();
d3.selectAll('.background').remove();
d3.selectAll('.overlay').remove();
return svg_brush.node();
}