choroplethData = {
return worldGeoJSON.features.map(countryFeature => {
const countryMultipleYears = dmft.filter(
country => country.iso_code == countryFeature.id
);
const yearValueMap = countryMultipleYears.reduce((acc, year) => {
acc[year.year_from] = year.dmft
if (year["Country Name"]) {
acc["Country Name"] = year["Country Name"]
}
return acc
}, {});
let latestValue = -1;
const filledMap = {"Country Name": yearValueMap["Country Name"]}
for (let i = minYear; i <= maxYear; i++) {
if (yearValueMap.hasOwnProperty(i)) {
latestValue = yearValueMap[i]
}
filledMap[i] = latestValue
}
countryFeature.properties = filledMap
return countryFeature;
});
}