Last active
July 23, 2020 02:30
-
-
Save JoBerkner/141d855ff6a8d963a5f5355f9bcd59fe to your computer and use it in GitHub Desktop.
manipulating the data for the visualization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Data Manipulation | |
const covidData = useMemo(() => { | |
const countriesAsArray = Object.keys(covidData_raw).map((country) => ({ | |
name: country, | |
data: covidData_raw[country] | |
})); | |
const windowSize = 7; | |
const countriesWithAvg = countriesAsArray.map(country => ({ | |
name: country.name, | |
data: [...movingAverage(country.data, windowSize)] | |
})); | |
const onlyCountriesWithData = countriesWithAvg.filter(country => | |
country.data.findIndex((d, _) => d[stat] >= 10) != -1 | |
); | |
return onlyCountriesWithData; | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment