Skip to content

Commit

Permalink
Add EU and EU+satelites as a new regions with sum of data of their me…
Browse files Browse the repository at this point in the history
…mbers
  • Loading branch information
Xubor committed Jul 7, 2020
1 parent 64859d6 commit a8e072e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions vue-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,19 @@ window.app = new Vue({
.map(e => Object.assign({}, e, {region: e['Province/State']}));
},

addSyntheticRegion(grouped, regionName, countries) {
const includedRegions = grouped.filter(e => countries.includes(e.region));
if (includedRegions.length == 0) return;

const newRegion = includedRegions.reduce((acc, cur) => {
for (const atr in cur) acc[atr] = (acc[atr] ? acc[atr] + cur[atr] : cur[atr]);
return acc;
}, {});
newRegion.region = regionName;

grouped.push(newRegion);
},

processData(data, selectedRegion, updateSelectedCountries) {
let dates = Object.keys(data[0]).slice(4);
this.dates = dates;
Expand All @@ -398,6 +411,21 @@ window.app = new Vue({
}
}

// additional regions computed from present country data
this.addSyntheticRegion(grouped, 'EU', [
'Austria', 'Belgium', 'Bulgaria', 'Croatia', 'Cyprus',
'Czechia', 'Denmark', 'Estonia', 'Finland', 'France',
'Germany', 'Greece', 'Hungary', 'Ireland', 'Italy',
'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Netherlands',
'Poland', 'Portugal', 'Romania', 'Slovakia', 'Slovenia',
'Spain', 'Sweden'
]);
this.addSyntheticRegion(grouped, 'EU+UK+EFTA+Microstates', [
'EU', 'United Kingdom',
'Iceland', 'Liechtenstein', 'Norway', 'Switzerland',
'Andorra', 'Monaco', 'San Marino', 'Holy See'
]);

} else {
grouped = this.filterByCountry(data, dates, selectedRegion)
.filter(e => !regionsToPullToCountryLevel.includes(e.region)); // also filter our Hong Kong and Macau as subregions of Mainland China
Expand Down

0 comments on commit a8e072e

Please # to comment.