viewof countyMap = {
const projection = d3.geoIdentity()
.fitSize([width, height], topojson.feature(geo, geo.objects.states.geometries.find(f => f.id === "48")));
const path = d3.geoPath();
path.projection(projection);
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height)
.attr("viewbox", [0, 0, width, height]);
svg.append("g")
.selectAll("path")
.data(topojson.feature(geo, geo.objects.counties).features.filter(d => d.id.slice(0, 2) === "48"))
.join("path")
.attr("fill", d => colorScale(turnoutPerc.get(d.id)))
.attr("d", path)
.on('mousemove', (event,d) => {
console.log(d.id.includes("48"))
d3.select(event.currentTarget)
.raise()
.style('stroke', "#000")
.style('stroke-width', 2)
.style('cursor', 'pointer');
event.preventDefault();
let [x,y] = d3.pointer(event)
let ttPos = positionTooltip(x,y);
let countyData = {
showTT: true,
FIPS: d.id,
mouse: {x: ttPos.x, y: ttPos.y}
}
updateCurrentCounty(countyData);
})
.on('mouseout', (event, d) => {
updateCurrentCounty({
showTT: false,
FIPS: null
});
d3.select(event.currentTarget).style('stroke', 'none').style('cursor', 'default');
})
.on('mousedown', (event,d) => {
event.preventDefault();
});
function updateCurrentCounty(d){
svg.node().value = d;
svg.node().dispatchEvent(new CustomEvent("input"));
}
updateCurrentCounty({
showTT: false,
FIPS: null
});
svg.append("path")
.datum(topojson.mesh(geo, geo.objects.states.geometries.find(f => f.id === "48"), (a, b) => a !== b))
.attr("fill", "none")
.attr("stroke", "#000")
.attr("stroke-linejoin", "round")
.attr("d", path);
return document.createElement("div").appendChild(svg.node());
}