Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
15 changes: 12 additions & 3 deletions src/api/EpiData.ts
Original file line number Diff line number Diff line change
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 @@ -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);
Expand All @@ -114,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 @@ -137,7 +142,7 @@ export function loadDataSet(
url.searchParams.set('format', 'json');
return fetchImpl<Record<string, unknown>[]>(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(
Expand Down Expand Up @@ -331,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 @@ -352,6 +357,10 @@ export function importFluView({
'num_age_4',
'num_age_5',
],
{
wili: '%wILI',
ili: '%ILI',
},
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/dialogs/ImportAPIDialog.svelte
Original file line number Diff line number Diff line change
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