enhancedSortedEmissionsByCountry = {
const dataCountries = new Map();
var countryIdx = 0;
sortedEmissionsByCountry.forEach((countryData, key, map) => {
const dataYears = [];
countryData.forEach((yearData, index) => {
const ghgPercentageDecrease = index == 0 ? 0 : Math.round(
(percentageDecrease(
map.get(key)[index - 1].total_ghg,
yearData.total_ghg
) +
Number.EPSILON) *
100
) / 100;
dataYears.push({
index,
country_idx: countryIdx,
iso_code: yearData.iso_code,
year: yearData.year,
total_ghg: yearData.total_ghg,
difference_from_base: yearData.diff_from_base,
yearly_change: ghgPercentageDecrease,
ghg_increased: ghgPercentageDecrease >= 0 ? false : true,
ghg_per_capita: parseFloat(yearData.ghg_per_capita)
});
});
dataYears.push()
dataCountries.set(key, dataYears);
countryIdx += 1;
});
return dataCountries;
}