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 b059736..7f08e1d 100644 --- a/src/api/EpiData.ts +++ b/src/api/EpiData.ts @@ -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[] = []; @@ -92,7 +94,9 @@ function loadEpidata( points.push(new EpiPoint(date, row[col] as number)); } if (points.length > 0) { - datasets.push(new DataSet(points, col, params)); + // 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); @@ -114,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) { @@ -137,7 +142,7 @@ export function loadDataSet( url.searchParams.set('format', 'json'); return fetchImpl[]>(url) .then((res) => { - const data = 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( @@ -331,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', @@ -352,6 +357,10 @@ export function importFluView({ 'num_age_4', 'num_age_5', ], + { + wili: '%wILI', + ili: '%ILI', + }, ); } diff --git a/src/components/dialogs/ImportAPIDialog.svelte b/src/components/dialogs/ImportAPIDialog.svelte index 21b380b..145bdff 100644 --- a/src/components/dialogs/ImportAPIDialog.svelte +++ b/src/components/dialogs/ImportAPIDialog.svelte @@ -72,7 +72,7 @@