wnc_surround = {
let map = d3
.create("svg")
.attr("width", map_width)
.attr("height", map_height)
.style('border', 'solid 2px black');
let county_group = map
.append("g")
.selectAll('path')
.data(counties.features)
.enter()
.append('path')
.attr('d', geoGenerator)
.style('stroke', 'black')
.style('stroke-width', '1px')
.style('stroke-opacity', 0.2)
.style('fill', function(d) {
let cases = d.properties.cases;
if (cases == 0) {
return 'white';
} else {
let s = 0.6;
if (d.properties.STATEFP == '37') {
return d3.interpolateBlues((d.properties.cases / max_cases) ** s);
} else {
return d3.interpolateReds((d.properties.cases / max_cases) ** s);
}
}
})
.on('mouseenter', function() {
d3.select(this)
.style('stroke-width', '4px')
.style('stroke-opacity', 0.8);
})
.on('mouseleave', function() {
d3.select(this)
.style('stroke-width', '1px')
.style('stroke-opacity', 0.2);
})
.attr('title', function(d) {
return `${
d.properties.NAME
} County, ${get_state(d.properties.STATEFP)}<br /> ${d.properties.cases} cases and ${d.properties.deaths} deaths<br />as of April 24`;
});
county_group.nodes().forEach(tippy);
map
.append("g")
.selectAll('path')
.data(states.features)
.enter()
.append('path')
.attr('d', geoGenerator)
.style('stroke', 'black')
.style('stroke-width', '3px')
.style('opacity', 0.7)
.style('fill', 'none');
let road_group = map.append("g");
road_group
.selectAll('path')
.data(roads.features)
.enter()
.append('path')
.attr('d', geoGenerator)
.style('fill', 'none')
.style('stroke-width', '4')
.style('stroke', '#ffffff')
.style('opacity', '0.9')
.attr('pointer-events', 'none');
let road_group2 = map.append("g");
road_group2
.selectAll('path')
.data(roads.features)
.enter()
.append('path')
.attr('d', geoGenerator)
.style('fill', 'none')
.style('stroke-width', '1.5')
.style('stroke', '#333')
.style('opacity', '0.7')
.attr('pointer-events', 'none');
map
.append('g')
.selectAll('circle')
.data(cities.features)
.enter()
.append('circle')
.attr('cx', function(d) {
let x =
projection.scale() * d.geometry.coordinates[0] +
projection.translate()[0];
return x;
})
.attr('cy', function(d) {
let y =
-projection.scale() * d.geometry.coordinates[1] +
projection.translate()[1];
return y;
})
.attr('r', 5)
.attr('fill', 'black');
map
.append('g')
.selectAll('text')
.data(cities.features)
.enter()
.append('text')
.attr('x', function(d) {
let x =
projection.scale() * d.geometry.coordinates[0] +
projection.translate()[0];
return x;
})
.attr('y', function(d) {
let y =
-projection.scale() * d.geometry.coordinates[1] +
projection.translate()[1];
return y;
})
.attr('dx', 8)
.attr('dy', function(d) {
if (d.properties.NAME == 'Atlanta') {
return 0;
} else if (d.properties.NAME == 'Knoxville') {
return 8;
} else {
return -5;
}
})
.text(d => d.properties.NAME)
.style('fill', function(d) {
if (d.properties.NAME == 'Atlanta') {
return 'white';
} else {
return 'black';
}
})
.style('font-size', '12px')
.attr('pointer-events', 'none');
return map.node();
}