data = {
let pieData = [];
let all = [
...cancerDeathRate,
...circulatoryDeathRate,
...respiratoryDeathRate,
...totalDeathRate,
...centroids
];
let merged = mergeObjectsInArray(all, "id").map(o => {
o.other = Math.round(o.total - o.cancer - o.circulatory - o.respiratory);
return o;
});
merged.filter(d => {
let countryCode = d.id.substring(0, 2);
if (!countryCode.includes("EU") && d.value !== null) {
pieData.push(
{
id: d.id,
name: d.name,
geometry: d.geometry,
total: d.total,
data: [
{ name: "Circulatory", value: d.circulatory },
{ name: "Cancer", value: d.cancer },
{ name: "Respiratory", value: d.respiratory },
{ name: "Other", value: d.other }
]
}
);
return d;
}
});
return pieData;
}