viewof CountyMap = {
let value = null;
const svg = d3.create("svg")
.attr("viewBox", [0, 0, 975, 610])
svg.append("g")
.selectAll("path")
.data(topojson.feature(geography, geography.objects.counties).features)
.enter().append("path")
.attr("d", path)
.attr("fill",
data =>
((_.find(populationData, feature => +feature.GEOID == +data.id)[populationVariable] > topQuantilePop)
&&
(_.find(normalizedDeathData, feature => +feature.fips == +data.id)[currentDate] > topQuantileDeath))
?
'rgb(0,0,0)'
:
'rgb(240,240,240)'
)
.attr('id', data => data.properties.name)
.attr('class', 'county');
svg.append("g")
.selectAll("path")
.data(topojson.feature(geography, geography.objects.states).features)
.enter().append("path")
.attr("d", path)
.attr("fill", 'none')
.attr("stroke", d => 'white')
.attr('id', d=> d.properties.name)
.attr('class', 'state');
svg.append("path")
.datum(topojson.mesh(geography, geography.objects.states, (a, b) => a !== b))
.attr("fill", "none")
.attr("stroke", d => 'white')
.attr("stroke-linejoin", "round")
.attr("pointer-events", "none")
.attr("d", path);
const tooltip = svg.append("g")
svg
.selectAll(".county")
.on("touchmove mousemove", function(event, d) {
tooltip.call(
callout,
`${d.properties.name}
`
);
tooltip.attr("transform", `translate(${d3.pointer(event, this)})`);
d3.select(this)
.raise();
})
.on("touchend mouseleave", function() {
tooltip.call(callout, null);
d3.select(this)
.attr("stroke", null)
.lower();
});
const outline = svg.append("path")
.attr("fill", "none")
.attr("stroke", "black")
.attr("stroke-linejoin", "round")
.attr("pointer-events", "none");
return Object.assign(svg.node(), {value: null});
}