{
const svg = d3.create('svg')
.attr('width', widthDiamond)
.attr('height', heightDiamond);
const groups = svg.append('g')
.selectAll('g.group')
.data(colorToCutToCount)
.join('g')
.attr('transform', d => `translate(${groupX(d[0])},0)`);
groups.selectAll('rect')
.data(d => Array.from(d[1], ([cut, count]) => ({cut, count})))
.join('rect')
.attr('x', d => barX(d.cut))
.attr('width', barX.bandwidth())
.attr('y', d => y(d.count))
.attr('height', d => y(0) - y(d.count))
.attr('fill', d => color(d.cut));
svg.append('g')
.attr('transform', `translate(0,${heightDiamond - marginDiamond.bottom})`)
.call(xAxisDiamond)
.call(g => g.select('.domain').remove())
.append('text')
.attr('x', widthDiamond / 2)
.attr('y', 30)
.attr('dominant-baseline', 'hanging')
.attr('text-align', 'middle')
.attr('fill', 'black')
.text('Diamond Color');
svg.append('g')
.attr('transform', `translate(${marginDiamond.left})`)
.call(yAxisDiamond)
.call(g => g.select('.domain').remove())
.append('text')
.attr('x', -50)
.attr('y', heightDiamond / 2)
.attr('dominant-baseline', 'middle')
.attr('text-align', 'end')
.attr('fill', 'black')
.text('Count');
return svg.node();
}