shapesWithDataCounty = curCountyShapes
.map(s => {
let curCountyResults = curData.filter(d=> d.FIPS == s.id)[0]
let curColor = curCountyResults && +curCountyResults.DemVotes == +curCountyResults.RepVotes ? '#ccc' :
curCountyResults && +curCountyResults.DemVotes > +curCountyResults.RepVotes ? '#2e74c0' :
'#cb454a';
let colRamp = d3.scaleLinear().domain([0, 1]).range(["#2e74c0", "#cb454a"])
let curColorRamped = colRamp(+curCountyResults.RepVotes / (+curCountyResults.DemVotes + +curCountyResults.RepVotes))
return ({
...s,
...curCountyResults,
color: curColor,
colorRamped: curColorRamped,
centroid: turf.centroid(s),
TotalVoters: (+curCountyResults.DemVotes) + (+curCountyResults.RepVotes) + (+curCountyResults.RemainingVotes)
})
})