data = {
let pieData = [];
let all = [
...wholesale,
...retail,
...food,
...employment,
...accommodation,
...totalEmployment,
...centroids
];
let merged = mergeObjectsInArray(all, "id").map((o) => {
o.other =
o.total > o.wholesale + o.retail + o.food + o.employment + o.accommodation
? Math.round(
o.total -
o.wholesale -
o.retail -
o.food -
o.employment -
o.accommodation
)
: 0;
return o;
});
merged.filter((d) => {
let countryCode = d.id.substring(0, 2);
if (!countryCode.includes("EU") && d.value !== null && d.geometry) {
pieData.push(
{
id: d.id,
name: d.name,
geometry: d.geometry,
total: d.total,
data: [
{ name: "Wholesale", value: d.wholesale },
{ name: "Retail", value: d.retail },
{ name: "Food", value: d.food },
{ name: "Employment", value: d.employment },
{ name: "Accommodation", value: d.accommodation },
{ name: "Other", value: d.other }
]
}
);
return d;
}
});
return pieData;
}