chart = {
const svg = d3.create('svg')
.attr('viewBox', [0, 0, 960, 700])
.style('background-color', '#fafafa');
svg.append('g')
.attr('transform', 'translate(20, 10)')
.append(() => legend({color,
title: 'Covid-19 Cases',
ticks: 4,
tickFormat: '.0s'}));
svg.append('g')
.selectAll('.cities')
.data(cityFeatures)
.join('path')
.attr('class', 'cities')
.attr('d', pathGenerator)
.attr('fill', d => {
let cases = d.properties.T_C_0621;
return cases === 'NA' || cases === undefined ?
'#636363' :
color(+cases);
})
.append('title')
.text(d => {
let cases = d.properties.T_C_0621;
return `${d.properties.City_EN} - ` +
(cases === undefined ? 'missing' : `${cases}`);
});
svg.append('g')
.selectAll('.provinces')
.data(provinceFeatures)
.join('path')
.attr('class', 'provinces')
.attr('d', pathGenerator)
.attr('fill', 'none')
.attr('stroke', 'white')
.attr('stroke-linejoin', 'round')
.attr('stroke-width', '0.7px');
return svg.node();
}