{
const margin = ({top: 10, bottom: 50, left: 85, right: 10});
const height = 600 - margin.top - margin.bottom;
const width = 800 - margin.left - margin.right;
const projection = d3.geoAlbers()
.fitSize([width, height], usaGeo)
const path = d3.geoPath().projection(projection)
const svg = d3.create('svg')
.attr('width', width + margin.left + margin.right)
.attr('height', height + margin.top + margin.bottom);
const g = svg.append('g')
.attr('transform', `translate(${margin.left}, ${margin.top})`);
const precincts = g.selectAll('path')
.data(usaGeo.features)
.join('path')
.attr('d', path)
.attr('fill', d => {
const nameToCode = stateToCode[d.properties.NAME];
const stateValuesAtDate = stateToDateToCount.get(nameToCode).get(date);
console.log('what is name to code');
console.log(nameToCode);
return colorByTime(stateValuesAtDate)
})
.attr('stroke', 'white')
return svg.node();
}