{
const svg = d3.create('svg')
.attr('width', 500)
.attr('height', 400);
const groups = svg.selectAll('g')
.data(rectsData)
.join('g')
.attr('transform', group => `translate(0,${group.y})`)
.attr('fill', group => group.color);
groups.append('text')
.attr('fill', 'black')
.attr('y', -5)
.text(group => group.title)
groups.selectAll('rect')
.data(group => group.bars)
.join('rect')
.attr('x', 0)
.attr('y', bar => bar.y)
.attr('width', bar => bar.width)
.attr('height', bar => bar.height);
return svg.node();
}