diff --git a/README.md b/README.md index 6e40d85..c31e60e 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Notice that most countries follow a similar straight line path, indicating that ## Credits -This interactive pulls data on COVID-19 provided by [Johns Hopkins CSSE](https://github.com/CSSEGISandData/COVID-19) and NYTimes. Huge thanks to them for making this invaluable data source publicly available. +This interactive pulls data on COVID-19 provided by [Johns Hopkins CSSE](https://github.com/CSSEGISandData/COVID-19). Huge thanks to them for making this invaluable data source publicly available. Created by [Aatish Bhatia](https://aatishb.com/) in collaboration with [Henry Reich](https://www.youtube.com/user/minutephysics). @@ -74,5 +74,5 @@ If you would like to participate or contribute, please read our [Contributor's G Code in this repository which is not otherwise licensed is licensed under the MIT License; see [LICENSE.txt](LICENSE.txt) for complete text. -This repository pulls data from [2019 Novel Coronavirus COVID-19 (2019-nCoV) Data Repository by Johns Hopkins CSSE](https://github.com/CSSEGISandData/COVID-19) and [New York Times Coronavirus (Covid-19) Data in the United States](https://github.com/nytimes/covid-19-data#license-and-attribution). Please consult these repositories for terms of use on the data. +This repository pulls data from [2019 Novel Coronavirus COVID-19 (2019-nCoV) Data Repository by Johns Hopkins CSSE](https://github.com/CSSEGISandData/COVID-19). Please consult these repositories for terms of use on the data. diff --git a/index.html b/index.html index 6d5917f..567ac54 100644 --- a/index.html +++ b/index.html @@ -94,7 +94,7 @@

{{ formatDate(minDay > 0 ? dates[day - 1] : dates[dates.length - 1]) }}

Not enough data for these parameters.
diff --git a/vue-definitions.js b/vue-definitions.js index cb81917..178dd80 100644 --- a/vue-definitions.js +++ b/vue-definitions.js @@ -297,9 +297,15 @@ let app = new Vue({ } Plotly.d3.csv(url, (data) => this.processData(data, selectedRegion, updateSelectedCountries)); } else { // selectedRegion == 'US' - const type = (selectedData == 'Reported Deaths') ? 'deaths' : 'cases' - const url = 'https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-states.csv'; - Plotly.d3.csv(url, (data) => this.processData(this.preprocessNYTData(data, type), selectedRegion, updateSelectedCountries)); + let url; + if (selectedData == 'Confirmed Cases') { + url = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_US.csv'; + } else if (selectedData == 'Reported Deaths') { + url = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_US.csv'; + } else { + return; + } + Plotly.d3.csv(url, (data) => this.processData(this.preprocessUSData(data), selectedRegion, updateSelectedCountries)); } }, @@ -369,7 +375,7 @@ let app = new Vue({ .filter(e => !regionsToPullToCountryLevel.includes(e.region)); // also filter our Hong Kong and Macau as subregions of Mainland China } - let exclusions = ['Cruise Ship', 'Diamond Princess']; + let exclusions = ['Cruise Ship', 'Diamond Princess', 'Grand Princess']; let renames = { 'Taiwan*': 'Taiwan', @@ -423,18 +429,21 @@ let app = new Vue({ }, - preprocessNYTData(data, type) { - let recastData = {}; - data.forEach(e => { - let st = recastData[e.state] = (recastData[e.state] || {'Province/State': e.state, 'Country/Region': 'US', 'Lat': null, 'Long': null}); - st[fixNYTDate(e.date)] = parseInt(e[type]); + preprocessUSData(data) { + let result = {}; + data.forEach(record => { + let region = record.Province_State + let temp = (result[region] || {'Province/State': region, 'Country/Region': 'US', 'Lat': null, 'Long': null}) + Object.keys(record).forEach(key => { + // if they key starts with a digit we assume it is a date + if (/^\d/.test(key)) { + // each record is a county so we sum them up to get the state wide total + temp[key] = (temp[key] || 0) + parseInt(record[key]) + } + }); + result[region] = temp }); - return Object.values(recastData); - - function fixNYTDate(date) { - let tmp = date.split('-'); - return `${tmp[1]}/${tmp[2]}/${tmp[0].substr(2)}`; - } + return Object.values(result); }, formatDate(date) { @@ -593,7 +602,7 @@ let app = new Vue({ return 'Countries'; case 'Australia': case 'US': - return 'States'; + return 'States and Territories'; case 'China': return 'Provinces'; case 'Canada':