{
const yScale = d3.scaleBand()
.domain(Array.from( new Set(selectedMonth.map( element => element.location )) ))
.range([0, visDimensions.height - margins.top - margins.bottom ])
.padding(0.2);
const xScale = d3.scaleLinear()
.domain(d3.extent(selectedMonth, d => d['total_cases']))
.range([10, visDimensions.width - margins.left - margins.right ]);
const colorScale = d3.scaleOrdinal()
.domain(Array.from( new Set(selectedMonth.map( element => element.location )) ))
.range(['#a6cee3','#1f78b4','#b2df8a','#33a02c','#fb9a99','#e31a1c','#fdbf6f','#ff7f00','#cab2d6','#6a3d9a'])
xAxisGroup.call( d3.axisTop(xScale).tickFormat(d3.format('.2s')) );
yAxisGroup.call( d3.axisLeft(yScale) );
chartGroup
.selectAll('.bar')
.data(selectedMonth, d => d.location )
.join(
enter => enter
.append('rect')
.attr('class', 'bar')
.attr('x', 10)
.attr('y', d => yScale(d.location))
.attr('width', d => xScale(d.total_cases))
.attr('height', 10)
.attr('fill', d => colorScale(d.location)),
update => update.transition()
.duration(500)
.attr('width', d => xScale(d.total_cases))
.attr('y', d => yScale(d.location)),
exit => exit.transition().duration(2000).attr('x', visDimensions.width ).attr('y', visDimensions.height ).remove()
);
}