populationData = {
let tempArray = [];
rawPopulationData.forEach((d,i) => {
if( d["Year.display-label"] == "July 1, 2018" && d["Sex.id"] == "totsex" && d["Hisp.id"] == "nhisp" ) {
let totpop = +rawPopulationData[i+1].totpop;
tempArray.push({
state: d["GEO.display-label"],
data: stack(level([
round(+d.wa/totpop*100, 2),
round(+d.ba/totpop*100, 2),
round(+rawPopulationData[i-1].totpop/totpop*100, 2),
round((+d.aa + +d.na)/totpop*100, 2),
round(100 - (round(+d.wa/totpop*100, 2) + round(+d.ba/totpop*100, 2) + round((+d.aa + +d.na)/totpop*100, 2) + round(+rawPopulationData[i-1].totpop/totpop*100, 2)), 2)]))
})
}
})
let tot = [8537673, 2737163, 1899379, 2489089, 1247479, 164563];
tempArray.push({
state: "New York City",
data: stack([
round(tot[1]/tot[0]*100, 2),
round(tot[2]/tot[0]*100, 2),
round(tot[3]/tot[0]*100, 2),
round(tot[4]/tot[0]*100, 2),
round(100 - (round(tot[1]/tot[0]*100, 2)+round(tot[2]/tot[0]*100, 2)+round(tot[3]/tot[0]*100, 2)+round(tot[4]/tot[0]*100, 2)),2) ])
});
return tempArray;
}