{
const svg = d3.create('svg')
.attr('width', width)
.attr('height', height);
const xAxis = d3.axisBottom(x).tickFormat(d3.timeFormat('%B'));
const yAxis = d3.axisLeft(yStacked);
svg.append('g')
.attr('transform', `translate(0,${height - margin.bottom})`)
.call(xAxis)
.call(g => g.selectAll('.domain').remove());
svg.append('g')
.attr('transform', `translate(${margin.left})`)
.call(yAxis)
.call(g => g.selectAll('.domain').remove())
.append('text')
.attr('fill', 'black')
.attr('text-anchor', 'start')
.attr('dominant-baseline', 'hanging')
.attr('font-weight', 'bold')
.attr('y', 5)
.attr('x', 0)
.text('Heridos por colisión, 2019');
svg.append('g')
.selectAll('path')
.data(stacked)
.join('path')
.attr('fill', d => color(d.key))
.attr('d', area);
svg.append('g')
.attr('transform', `translate(${margin.left},${margin.top - 15})`)
.selectAll('g.legend-item')
.data(boroughs)
.join('g')
.attr('class', 'legend-item')
.attr('transform', (d, i) => `translate(${i * 150},0)`)
.each(function(d) {
d3.select(this)
.append('rect')
.attr('width', 15)
.attr('height', 15)
.attr('fill', color(d));
d3.select(this)
.append('text')
.attr('x', 16)
.attr('y', 15)
.text(d);
});
return svg.node();
}