{
const svg = d3.create('svg')
.attr('width', width + 100)
.attr('height', height)
const hex = svg.append('g')
.selectAll('.hexagon')
.data(hexbin(svgData))
.enter().append('g')
.attr('class', 'hexagon')
.attr('transform', d => `translate(${d.x}, ${d.y})`)
hex.append('path')
.attr('d', hexbin.hexagon())
.attr('stroke', '#eee')
.attr('stroke-opacity', '0.5')
.attr('stroke-width', '1px')
.style('fill', d => (d[0].index >= pctValue) ? '#bfabcc' : '#6b2e63')
if (numbersDisplay.includes('numbers')) {
hex.append('text')
.style('font-size', '8px')
.attr('text-anchor', 'middle')
.attr('y', '2px')
.style('fill', d => (d[0].index >= pctValue) ? '#000' : '#fff')
.text(d => d[0].index + 1)
}
svg.append('text')
.style('fill', '#6b2e63')
.attr('x', '500px')
.attr('y', '400px')
.style('font-size', '60px')
.text(pctValue + '%')
return svg.node()
}