mapSizedByVote = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg
.append("g")
.selectAll("circle")
.data(circles.filter(d => !!d.winner))
.join("circle")
.attr("fill", d => {
let tt = nytPresCountiesByFIPS.get(d.id);
if (!tt) return "lightgray";
if (tt.results.trumpd < tt.results.bidenj) {
return blue;
} else if (tt.results.trumpd > tt.results.bidenj) {
return red;
}
return "lightgray";
})
.attr("stroke", d => {
let problem = shirleyDataByFIPS.get(d.id);
if (problem) {
return "orange";
}
return "none";
})
.attr("opacity", d => {
let tt = nytPresCountiesByFIPS.get(d.id);
if (!tt) return 0.1;
return (
0.2 + tt.votes / (tt.tot_exp_vote ? tt.tot_exp_vote : tt.votes2016)
);
})
.attr("cx", d => d.x)
.attr("cy", d => d.y)
.attr("r", d => {
let tt = nytPresCountiesByFIPS.get(d.id);
if (!tt) return false;
let r = tt.tot_exp_vote ? tt.tot_exp_vote : tt.votes2016;
r = Math.sqrt(r * 0.001) * 0.4 + 1;
return r;
})
.on("click", (event, d) => {
let tt = nytPresCountiesByFIPS.get(d.id);
console.log("county", d, tt);
})
.append("title")
.text(d => d.properties.name);
return svg.node();
}