diff --git a/package-lock.json b/package-lock.json index a329f90..b6ceb0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "www-epivis", - "version": "2.1.3", + "version": "2.1.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "www-epivis", - "version": "2.1.3", + "version": "2.1.4", "license": "MIT", "dependencies": { "uikit": "^3.15.5" diff --git a/package.json b/package.json index 97aa2e6..472d575 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "www-epivis", - "version": "2.1.3", + "version": "2.1.4", "private": true, "license": "MIT", "description": "", diff --git a/src/App.svelte b/src/App.svelte index 047c4d7..e5b147f 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -31,8 +31,8 @@ if (ds) { // add the dataset itself addDataSet(ds); - // reset active datasets to fluview -> ili - $activeDatasets = [ds.datasets[1]]; + // reset active datasets to fluview -> wili + $activeDatasets = [ds.datasets[0]]; if (chart) { chart.fitData(true); } diff --git a/src/api/EpiData.ts b/src/api/EpiData.ts index 866063e..1b3dfc5 100644 --- a/src/api/EpiData.ts +++ b/src/api/EpiData.ts @@ -9,7 +9,7 @@ import { fluViewRegions, gftLocations, ghtLocations, - nidssDenqueLocations, + nidssDengueLocations, nidssFluLocations, nowcastLocations, quidelLocations, @@ -64,9 +64,11 @@ function loadEpidata( name: string, epidata: Record[], columns: string[], + columnRenamings: Record, params: Record, ): DataGroup { const datasets: DataSet[] = []; + const colRenamings = new Map(Object.entries(columnRenamings)); for (const col of columns) { const points: EpiPoint[] = []; @@ -91,7 +93,11 @@ function loadEpidata( } points.push(new EpiPoint(date, row[col] as number)); } - datasets.push(new DataSet(points, col, params)); + if (points.length > 0) { + // overwrite default column name if there's an overwrite in columnRenamings + const title = colRenamings.has(col) ? colRenamings.get(col) : col; + datasets.push(new DataSet(points, title, params)); + } } return new DataGroup(name, datasets); } @@ -112,6 +118,7 @@ export function loadDataSet( fixedParams: Record, userParams: Record, columns: string[], + columnRenamings: Record = {}, ): Promise { const duplicates = get(expandedDataGroups).filter((d) => d.title == title); if (duplicates.length > 0) { @@ -135,7 +142,18 @@ export function loadDataSet( url.searchParams.set('format', 'json'); return fetchImpl[]>(url) .then((res) => { - return loadEpidata(title, res, columns, { _endpoint: endpoint, ...params }); + const data = loadEpidata(title, res, columns, columnRenamings, { _endpoint: endpoint, ...params }); + if (data.datasets.length == 0) { + return UIkit.modal + .alert( + ` +
+ API Link returned no data. +
`, + ) + .then(() => null); + } + return data; }) .catch((error) => { console.warn('failed fetching data', error); @@ -318,7 +336,7 @@ export function importFluView({ auth?: string; }): Promise { const regionLabel = fluViewRegions.find((d) => d.value === regions)?.label ?? '?'; - const title = appendIssueToTitle(`[API] FluView: ${regionLabel}`, { issues, lag }); + const title = appendIssueToTitle(`[API] ILINet (aka FluView): ${regionLabel}`, { issues, lag }); return loadDataSet( title, 'fluview', @@ -339,6 +357,10 @@ export function importFluView({ 'num_age_4', 'num_age_5', ], + { + wili: '%wILI', + ili: '%ILI', + }, ); } @@ -378,9 +400,9 @@ export function importGHT({ ); } -export function importNIDSSDenque({ locations }: { locations: string }): Promise { - const regionLabel = nidssDenqueLocations.find((d) => d.value === locations)?.label ?? '?'; - const title = `[API] NIDSS-Denque: ${regionLabel}`; +export function importNIDSSDengue({ locations }: { locations: string }): Promise { + const regionLabel = nidssDengueLocations.find((d) => d.value === locations)?.label ?? '?'; + const title = `[API] NIDSS-Dengue: ${regionLabel}`; return loadDataSet( title, 'nidss_dengue', diff --git a/src/components/TopMenu.svelte b/src/components/TopMenu.svelte index 878a698..6545423 100644 --- a/src/components/TopMenu.svelte +++ b/src/components/TopMenu.svelte @@ -49,11 +49,6 @@ return; } switch (e.key) { - case 'f': - if (chart) { - chart.fitData(true); - } - break; case 'a': $navMode = NavMode.autofit; break; diff --git a/src/components/dialogs/ImportAPIDialog.svelte b/src/components/dialogs/ImportAPIDialog.svelte index 21b380b..2d48895 100644 --- a/src/components/dialogs/ImportAPIDialog.svelte +++ b/src/components/dialogs/ImportAPIDialog.svelte @@ -36,7 +36,7 @@ | 'cdc' | 'quidel' | 'nidss_flu' - | 'nidss_denque' + | 'nidss_dengue' | 'sensors' | 'nowcast' | 'covidcast' @@ -72,7 +72,7 @@