Public
Edited
Dec 26, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
choroplethData = {
return worldGeoJSON.features.map(countryFeature => {
// ISO-3166 Code
const countryMultipleYears = dmft.filter(
country => country.iso_code == countryFeature.id
);

// Actual year-value map
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;
// Fill all the holes with previous data
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;
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {interval} from '@mootari/range-slider@1781'
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more