{
const svg = d3.create('svg')
.attr('width', width)
.attr('height', height);
const innerWidth = width - margin.left - margin.right;
const innerHeight = height - margin.top - margin.bottom;
svg.append('g')
.attr('transform', `translate(0,${height - margin.bottom})`)
.call(xAxis);
svg.append('g')
.attr('transform', `translate(${margin.left})`)
.call(yAxis)
.call(g => g.select('.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');
const line = d3.line()
.x(d => x(d.date))
.y(d => y(d.injuries));
const linesGroup = svg.append('g')
.attr('transform', `translate(${margin.left},${margin.top})`);
linesGroup.selectAll('circle')
.data(dataByBorough.flatMap(d => d.counts))
.join('circle')
.attr('cx', d => x(d.date))
.attr('cy', d => y(d.injuries))
.attr('r', 3)
.attr('fill', 'red');
linesGroup.selectAll('path')
.data(dataByBorough)
.join('path')
.attr('d', d => line(d.counts))
.attr('stroke', d => color(d.borough))
.attr('fill', 'none')
.attr('stroke-width', 2);
return svg.node();
}