{
const svg = d3.create('svg')
.attr('width', totalWidth).attr('height', totalHeight);
const x = d3.scaleTime()
.domain(d3.extent(months))
.range([0, visWidth]);
const row = d3.scaleBand()
.domain(boroughs)
.range([0, visHeight])
.paddingInner(0.25);
const y = d3.scaleLinear()
.domain([0, maxSingleBoroughInjuries]).nice()
.range([row.bandwidth(), 0]);
const color = d3.scaleOrdinal()
.domain(boroughs)
.range(d3.schemeTableau10);
const area = d3.area()
.x(d => x(d.date))
.y1(d => y(d.injuries))
.y0(d => y(0));
const g = svg.append("g")
.attr('transform', `translate(${margin.left}, ${margin.top})`);
const rows = g.append('g')
.selectAll('g')
.data(dataByBorough)
.join('g')
.attr('transform', d => `translate(0, ${row(d.borough)})`)
.attr('fill', d => color(d.borough))
const xAxis = d3.axisBottom(x).tickFormat(d3.timeFormat('%B'));
const yAxis = d3.axisLeft(y).ticks(5);
g.append('g')
.attr('transform', `translate(0, ${visHeight})`)
.call(xAxis);
rows.append('g')
.attr('class', 'y-axis')
.call(yAxis)
.call(g => g.select('.domain').remove());
rows.append('text')
.text(d => d.borough)
.attr('font-size', 12)
.attr('fill', 'black')
.attr('font-family', 'sans-serif')
.attr('y', 10)
.attr('x', 5);
g.select('.y-axis')
.append('text')
.attr('fill', 'black')
.attr('text-anchor', 'start')
.attr('dominant-baseline', 'middle')
.attr('y', -10)
.attr('x', -10)
.text('Injured Count');
rows.append('path')
.attr('d', d => area(d.counts));
return svg.node();
}