Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v2.1.4 #70

Merged
merged 13 commits into from
Sep 26, 2024
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "www-epivis",
"version": "2.1.3",
"version": "2.1.4",
"private": true,
"license": "MIT",
"description": "",
Expand Down
4 changes: 2 additions & 2 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
36 changes: 29 additions & 7 deletions src/api/EpiData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
fluViewRegions,
gftLocations,
ghtLocations,
nidssDenqueLocations,
nidssDengueLocations,
nidssFluLocations,
nowcastLocations,
quidelLocations,
Expand Down Expand Up @@ -64,9 +64,11 @@ function loadEpidata(
name: string,
epidata: Record<string, unknown>[],
columns: string[],
columnRenamings: Record<string, string>,
params: Record<string, unknown>,
): DataGroup {
const datasets: DataSet[] = [];
const colRenamings = new Map(Object.entries(columnRenamings));

for (const col of columns) {
const points: EpiPoint[] = [];
Expand All @@ -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);
}
Expand All @@ -112,6 +118,7 @@ export function loadDataSet(
fixedParams: Record<string, unknown>,
userParams: Record<string, unknown>,
columns: string[],
columnRenamings: Record<string, string> = {},
): Promise<DataGroup | null> {
const duplicates = get(expandedDataGroups).filter((d) => d.title == title);
if (duplicates.length > 0) {
Expand All @@ -135,7 +142,18 @@ export function loadDataSet(
url.searchParams.set('format', 'json');
return fetchImpl<Record<string, unknown>[]>(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(
`
<div class="uk-alert uk-alert-error">
<a href="${url.href}">API Link</a> returned no data.
</div>`,
)
.then(() => null);
}
return data;
})
.catch((error) => {
console.warn('failed fetching data', error);
Expand Down Expand Up @@ -318,7 +336,7 @@ export function importFluView({
auth?: string;
}): Promise<DataGroup | null> {
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',
Expand All @@ -339,6 +357,10 @@ export function importFluView({
'num_age_4',
'num_age_5',
],
{
wili: '%wILI',
ili: '%ILI',
},
);
}

Expand Down Expand Up @@ -378,9 +400,9 @@ export function importGHT({
);
}

export function importNIDSSDenque({ locations }: { locations: string }): Promise<DataGroup | null> {
const regionLabel = nidssDenqueLocations.find((d) => d.value === locations)?.label ?? '?';
const title = `[API] NIDSS-Denque: ${regionLabel}`;
export function importNIDSSDengue({ locations }: { locations: string }): Promise<DataGroup | null> {
const regionLabel = nidssDengueLocations.find((d) => d.value === locations)?.label ?? '?';
const title = `[API] NIDSS-Dengue: ${regionLabel}`;
return loadDataSet(
title,
'nidss_dengue',
Expand Down
5 changes: 0 additions & 5 deletions src/components/TopMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@
return;
}
switch (e.key) {
case 'f':
if (chart) {
chart.fitData(true);
}
break;
case 'a':
$navMode = NavMode.autofit;
break;
Expand Down
6 changes: 3 additions & 3 deletions src/components/dialogs/ImportAPIDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
| 'cdc'
| 'quidel'
| 'nidss_flu'
| 'nidss_denque'
| 'nidss_dengue'
| 'sensors'
| 'nowcast'
| 'covidcast'
Expand Down Expand Up @@ -72,7 +72,7 @@
<div class="uk-form-controls uk-form-controls-text">
<label
><input class="uk-radio" type="radio" name="dataSource" bind:group={dataSource} value="fluview" />
FluView (source:
ILINet (aka FluView) (source:
<a target="_blank" href="https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html">cdc.gov</a>)
</label>
<label
Expand Down Expand Up @@ -156,7 +156,7 @@
<Wiki {id} bind:this={handler} />
{:else if dataSource === 'quidel'}
<Quidel {id} bind:this={handler} />
{:else if dataSource === 'nidss_denque'}
{:else if dataSource === 'nidss_dengue'}
<NidssDengue {id} bind:this={handler} />
{:else if dataSource === 'nidss_flu'}
<NidssFlu {id} bind:this={handler} />
Expand Down
6 changes: 3 additions & 3 deletions src/components/dialogs/dataSources/NIDSSDengue.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script lang="ts">
import { importNIDSSDenque } from '../../../api/EpiData';
import { nidssDenqueLocations as regions } from '../../../data/data';
import { importNIDSSDengue } from '../../../api/EpiData';
import { nidssDengueLocations as regions } from '../../../data/data';
import SelectField from '../inputs/SelectField.svelte';

export let id: string;

let locations = regions[0].value;

export function importDataSet() {
return importNIDSSDenque({ locations });
return importNIDSSDengue({ locations });
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/data/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export const nidssFluLocations = [
{ value: 'taipei', label: 'Taipei' },
];

export const nidssDenqueLocations = [
export const nidssDengueLocations = [
{ value: 'nationwide', label: 'Taiwan National' },
{ value: 'central', label: 'Central' },
{ value: 'eastern', label: 'Eastern' },
Expand Down
4 changes: 2 additions & 2 deletions src/deriveLinkDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
importFluView,
importGFT,
importGHT,
importNIDSSDenque,
importNIDSSDengue,
importNIDSSFlu,
importNowcast,
importQuidel,
Expand Down Expand Up @@ -53,7 +53,7 @@ const lookups = {
fluview: importFluView,
gft: importGFT,
ght: importGHT,
nidss_denque: importNIDSSDenque,
nidss_dengue: importNIDSSDengue,
nidss_flu: importNIDSSFlu,
nowcast: importNowcast,
quidel: importQuidel,
Expand Down