Skip to content

Commit 4fcef78

Browse files
authored
Merge pull request #66 from cmu-delphi/rzatserkovnyi/fluview-display
Update default FluView display
2 parents 07bd680 + aba0e9a commit 4fcef78

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/App.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
if (ds) {
3232
// add the dataset itself
3333
addDataSet(ds);
34-
// reset active datasets to fluview -> ili
35-
$activeDatasets = [ds.datasets[1]];
34+
// reset active datasets to fluview -> wili
35+
$activeDatasets = [ds.datasets[0]];
3636
if (chart) {
3737
chart.fitData(true);
3838
}

src/api/EpiData.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ function loadEpidata(
6464
name: string,
6565
epidata: Record<string, unknown>[],
6666
columns: string[],
67+
columnRenamings: Record<string, string>,
6768
params: Record<string, unknown>,
6869
): DataGroup {
6970
const datasets: DataSet[] = [];
71+
const colRenamings = new Map(Object.entries(columnRenamings));
7072

7173
for (const col of columns) {
7274
const points: EpiPoint[] = [];
@@ -92,7 +94,9 @@ function loadEpidata(
9294
points.push(new EpiPoint(date, row[col] as number));
9395
}
9496
if (points.length > 0) {
95-
datasets.push(new DataSet(points, col, params));
97+
// overwrite default column name if there's an overwrite in columnRenamings
98+
const title = colRenamings.has(col) ? colRenamings.get(col) : col;
99+
datasets.push(new DataSet(points, title, params));
96100
}
97101
}
98102
return new DataGroup(name, datasets);
@@ -114,6 +118,7 @@ export function loadDataSet(
114118
fixedParams: Record<string, unknown>,
115119
userParams: Record<string, unknown>,
116120
columns: string[],
121+
columnRenamings: Record<string, string> = {},
117122
): Promise<DataGroup | null> {
118123
const duplicates = get(expandedDataGroups).filter((d) => d.title == title);
119124
if (duplicates.length > 0) {
@@ -137,7 +142,7 @@ export function loadDataSet(
137142
url.searchParams.set('format', 'json');
138143
return fetchImpl<Record<string, unknown>[]>(url)
139144
.then((res) => {
140-
const data = loadEpidata(title, res, columns, { _endpoint: endpoint, ...params });
145+
const data = loadEpidata(title, res, columns, columnRenamings, { _endpoint: endpoint, ...params });
141146
if (data.datasets.length == 0) {
142147
return UIkit.modal
143148
.alert(
@@ -331,7 +336,7 @@ export function importFluView({
331336
auth?: string;
332337
}): Promise<DataGroup | null> {
333338
const regionLabel = fluViewRegions.find((d) => d.value === regions)?.label ?? '?';
334-
const title = appendIssueToTitle(`[API] FluView: ${regionLabel}`, { issues, lag });
339+
const title = appendIssueToTitle(`[API] ILINet (aka FluView): ${regionLabel}`, { issues, lag });
335340
return loadDataSet(
336341
title,
337342
'fluview',
@@ -352,6 +357,10 @@ export function importFluView({
352357
'num_age_4',
353358
'num_age_5',
354359
],
360+
{
361+
wili: '%wILI',
362+
ili: '%ILI',
363+
},
355364
);
356365
}
357366

src/components/dialogs/ImportAPIDialog.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<div class="uk-form-controls uk-form-controls-text">
7373
<label
7474
><input class="uk-radio" type="radio" name="dataSource" bind:group={dataSource} value="fluview" />
75-
FluView (source:
75+
ILINet (aka FluView) (source:
7676
<a target="_blank" href="https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html">cdc.gov</a>)
7777
</label>
7878
<label

0 commit comments

Comments
 (0)