Skip to content

Commit 78415eb

Browse files
authored
Merge pull request #70 from cmu-delphi/release/v2.1.4
Release v2.1.4
2 parents 0259bbe + d344557 commit 78415eb

File tree

9 files changed

+43
-26
lines changed

9 files changed

+43
-26
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "www-epivis",
3-
"version": "2.1.3",
3+
"version": "2.1.4",
44
"private": true,
55
"license": "MIT",
66
"description": "",

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: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
fluViewRegions,
1010
gftLocations,
1111
ghtLocations,
12-
nidssDenqueLocations,
12+
nidssDengueLocations,
1313
nidssFluLocations,
1414
nowcastLocations,
1515
quidelLocations,
@@ -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[] = [];
@@ -91,7 +93,11 @@ function loadEpidata(
9193
}
9294
points.push(new EpiPoint(date, row[col] as number));
9395
}
94-
datasets.push(new DataSet(points, col, params));
96+
if (points.length > 0) {
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));
100+
}
95101
}
96102
return new DataGroup(name, datasets);
97103
}
@@ -112,6 +118,7 @@ export function loadDataSet(
112118
fixedParams: Record<string, unknown>,
113119
userParams: Record<string, unknown>,
114120
columns: string[],
121+
columnRenamings: Record<string, string> = {},
115122
): Promise<DataGroup | null> {
116123
const duplicates = get(expandedDataGroups).filter((d) => d.title == title);
117124
if (duplicates.length > 0) {
@@ -135,7 +142,18 @@ export function loadDataSet(
135142
url.searchParams.set('format', 'json');
136143
return fetchImpl<Record<string, unknown>[]>(url)
137144
.then((res) => {
138-
return loadEpidata(title, res, columns, { _endpoint: endpoint, ...params });
145+
const data = loadEpidata(title, res, columns, columnRenamings, { _endpoint: endpoint, ...params });
146+
if (data.datasets.length == 0) {
147+
return UIkit.modal
148+
.alert(
149+
`
150+
<div class="uk-alert uk-alert-error">
151+
<a href="${url.href}">API Link</a> returned no data.
152+
</div>`,
153+
)
154+
.then(() => null);
155+
}
156+
return data;
139157
})
140158
.catch((error) => {
141159
console.warn('failed fetching data', error);
@@ -318,7 +336,7 @@ export function importFluView({
318336
auth?: string;
319337
}): Promise<DataGroup | null> {
320338
const regionLabel = fluViewRegions.find((d) => d.value === regions)?.label ?? '?';
321-
const title = appendIssueToTitle(`[API] FluView: ${regionLabel}`, { issues, lag });
339+
const title = appendIssueToTitle(`[API] ILINet (aka FluView): ${regionLabel}`, { issues, lag });
322340
return loadDataSet(
323341
title,
324342
'fluview',
@@ -339,6 +357,10 @@ export function importFluView({
339357
'num_age_4',
340358
'num_age_5',
341359
],
360+
{
361+
wili: '%wILI',
362+
ili: '%ILI',
363+
},
342364
);
343365
}
344366

@@ -378,9 +400,9 @@ export function importGHT({
378400
);
379401
}
380402

381-
export function importNIDSSDenque({ locations }: { locations: string }): Promise<DataGroup | null> {
382-
const regionLabel = nidssDenqueLocations.find((d) => d.value === locations)?.label ?? '?';
383-
const title = `[API] NIDSS-Denque: ${regionLabel}`;
403+
export function importNIDSSDengue({ locations }: { locations: string }): Promise<DataGroup | null> {
404+
const regionLabel = nidssDengueLocations.find((d) => d.value === locations)?.label ?? '?';
405+
const title = `[API] NIDSS-Dengue: ${regionLabel}`;
384406
return loadDataSet(
385407
title,
386408
'nidss_dengue',

src/components/TopMenu.svelte

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@
4949
return;
5050
}
5151
switch (e.key) {
52-
case 'f':
53-
if (chart) {
54-
chart.fitData(true);
55-
}
56-
break;
5752
case 'a':
5853
$navMode = NavMode.autofit;
5954
break;

src/components/dialogs/ImportAPIDialog.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
| 'cdc'
3737
| 'quidel'
3838
| 'nidss_flu'
39-
| 'nidss_denque'
39+
| 'nidss_dengue'
4040
| 'sensors'
4141
| 'nowcast'
4242
| 'covidcast'
@@ -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
@@ -156,7 +156,7 @@
156156
<Wiki {id} bind:this={handler} />
157157
{:else if dataSource === 'quidel'}
158158
<Quidel {id} bind:this={handler} />
159-
{:else if dataSource === 'nidss_denque'}
159+
{:else if dataSource === 'nidss_dengue'}
160160
<NidssDengue {id} bind:this={handler} />
161161
{:else if dataSource === 'nidss_flu'}
162162
<NidssFlu {id} bind:this={handler} />

src/components/dialogs/dataSources/NIDSSDengue.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<script lang="ts">
2-
import { importNIDSSDenque } from '../../../api/EpiData';
3-
import { nidssDenqueLocations as regions } from '../../../data/data';
2+
import { importNIDSSDengue } from '../../../api/EpiData';
3+
import { nidssDengueLocations as regions } from '../../../data/data';
44
import SelectField from '../inputs/SelectField.svelte';
55
66
export let id: string;
77
88
let locations = regions[0].value;
99
1010
export function importDataSet() {
11-
return importNIDSSDenque({ locations });
11+
return importNIDSSDengue({ locations });
1212
}
1313
</script>
1414

src/data/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export const nidssFluLocations = [
315315
{ value: 'taipei', label: 'Taipei' },
316316
];
317317

318-
export const nidssDenqueLocations = [
318+
export const nidssDengueLocations = [
319319
{ value: 'nationwide', label: 'Taiwan National' },
320320
{ value: 'central', label: 'Central' },
321321
{ value: 'eastern', label: 'Eastern' },

src/deriveLinkDefaults.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
importFluView,
77
importGFT,
88
importGHT,
9-
importNIDSSDenque,
9+
importNIDSSDengue,
1010
importNIDSSFlu,
1111
importNowcast,
1212
importQuidel,
@@ -53,7 +53,7 @@ const lookups = {
5353
fluview: importFluView,
5454
gft: importGFT,
5555
ght: importGHT,
56-
nidss_denque: importNIDSSDenque,
56+
nidss_dengue: importNIDSSDengue,
5757
nidss_flu: importNIDSSFlu,
5858
nowcast: importNowcast,
5959
quidel: importQuidel,

0 commit comments

Comments
 (0)