Skip to content

Instantly share code, notes, and snippets.

@JoBerkner
Last active July 23, 2020 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoBerkner/141d855ff6a8d963a5f5355f9bcd59fe to your computer and use it in GitHub Desktop.
Save JoBerkner/141d855ff6a8d963a5f5355f9bcd59fe to your computer and use it in GitHub Desktop.
manipulating the data for the visualization
//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