chart = {
const svg = d3.create('svg')
.attr('viewBox', [0, 0, width, height])
.attr('style', 'border: 1px solid #eee')
.attr('xmlns', 'http://www.w3.org/2000/svg')
svg.call(xAxis);
svg.call(yAxis)
svg.append("g")
.selectAll('g')
.data(chartData)
.join("g")
.style('fill', (d, i) => {
const c = d3.color(color(d.key));
const start = c.toString();
c.opacity = 0.4;
const end = c.toString();
gradient(svg, d.key, start, end);
return `url(#${d.key})`
})
.selectAll('rect')
.data(d => {
return d;
})
.join('rect')
.attr('x', d => xScale(d.data.xKey))
.attr('y', d => yScale(d[1]))
.attr('height', d => yScale(d[0]) - yScale(d[1]))
.attr('width', xScale.bandwidth())
return svg.node();
}