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 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.10",
"version": "2.1.11",
"private": true,
"license": "MIT",
"description": "",
Expand Down
29 changes: 29 additions & 0 deletions src/api/EpiData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,35 @@ export function importFluView({
});
}

export function importFluViewClinical({
regions,
issues,
lag,
}: {
regions: string;
issues?: number | null;
lag?: number | null;
}): Promise<DataGroup | null> {
const regionLabel = fluViewRegions.find((d) => d.value === regions)?.label ?? '?';
const title = appendIssueToTitle(`[API] FluView Clinical: ${regionLabel}`, { issues, lag });
return loadDataSet(
title,
'fluview_clinical',
{
epiweeks: epiRange(firstEpiWeek.fluview, currentEpiWeek),
},
{ regions, issues, lag },
['total_specimens', 'total_a', 'total_b', 'percent_positive', 'percent_a', 'percent_b'],
).then((ds) => {
// get inside the Promise and make sure its not null,
// then enable display of 'percent_positive' data
if (ds instanceof DataGroup) {
ds.defaultEnabled = ['percent_positive'];
}
return ds;
});
}

export function importGFT({ locations }: { locations: string }): Promise<DataGroup | null> {
const regionLabel = gftLocations.find((d) => d.value === locations)?.label ?? '?';
const title = `[API] GFT: ${regionLabel}`;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Chart.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@
let labelOffset = 0;
for (const ds of datasets) {
ctx.fillStyle = ds.color;
const label = `— ${ds.title}`;
const label = `— ${ds.displayTitle()}`;
drawText(ctx, label, width - 10, height - 10 - labelOffset, 0, Align.right, Align.bottom);
labelOffset += 12;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/LeftMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<side class="left" {style} data-tour="browser">
<ImportDataSetsMenu />
<div class="tree">
{#each $datasetTree.datasets as child (child.title)}
{#each $datasetTree.datasets as child (child.displayTitle())}
{#if child instanceof DataSet}
<TreeLeafNode {chart} node={child} />
{:else}
Expand Down
14 changes: 14 additions & 0 deletions src/components/dialogs/ImportAPIDialog.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import FluSurv from './dataSources/FluSurv.svelte';
import FluView from './dataSources/FluView.svelte';
import FluViewClinical from './dataSources/FluViewClinical.svelte';

import { createEventDispatcher } from 'svelte';

Expand Down Expand Up @@ -81,6 +82,17 @@
>cmu-delphi.github.io</a
>)</label
>
<label
><input
class="uk-radio"
type="radio"
name="dataSource"
bind:group={$formSelections.dataSource}
value="fluview_clinical"
/>
FluView Clinical (source:
<a target="_blank" href="https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html">cdc.gov</a>)
</label>
<label
><input
class="uk-radio"
Expand Down Expand Up @@ -200,6 +212,8 @@

{#if $formSelections.dataSource === 'fluview'}
<FluView {id} bind:this={handler} />
{:else if $formSelections.dataSource === 'fluview_clinical'}
<FluViewClinical {id} bind:this={handler} />
{:else if $formSelections.dataSource === 'flusurv'}
<FluSurv {id} bind:this={handler} />
{:else if $formSelections.dataSource === 'gft'}
Expand Down
24 changes: 24 additions & 0 deletions src/components/dialogs/dataSources/FluViewClinical.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script lang="ts">
import { importFluViewClinical } from '../../../api/EpiData';
import { fluViewRegions } from '../../../data/data';
import SelectField from '../inputs/SelectField.svelte';
import SelectIssue from '../inputs/SelectIssue.svelte';
import { formSelections } from '../../../store';

export let id: string;

export function importDataSet() {
return importFluViewClinical({
regions: $formSelections.fluViewClinical.locations,
...$formSelections.fluViewClinical.issue,
});
}
</script>

<SelectField
id="{id}-r"
label="Region"
bind:value={$formSelections.fluViewClinical.locations}
options={fluViewRegions}
/>
<SelectIssue {id} bind:value={$formSelections.fluViewClinical.issue} />
7 changes: 7 additions & 0 deletions src/components/dialogs/formSelections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export class FluViewSelections {
issue = DEFAULT_ISSUE;
}

export class FluViewClinicalSelections {
locations = fluViewRegions[0].value;
issue = DEFAULT_ISSUE;
}

export class GftSelections {
locations = gftLocations[0].value;
}
Expand Down Expand Up @@ -93,6 +98,7 @@ export class WikiSelections {
export default class FormSelections {
dataSource:
| 'fluview'
| 'fluview_clinical'
| 'flusurv'
| 'gft'
| 'ght'
Expand All @@ -111,6 +117,7 @@ export default class FormSelections {
covidHosp = new CovidHospSelections();
fluSurv = new FluSurvSelections();
fluView = new FluViewSelections();
fluViewClinical = new FluViewClinicalSelections();
gft = new GftSelections();
ght = new GhtSelections();
nidssDengue = new NidssDengueSelections();
Expand Down
4 changes: 2 additions & 2 deletions src/components/tree/TreeInnerNode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
<span on:click={toggleExpanded}>
<Fa icon={expanded ? faChevronDown : faChevronRight} style="width: 0.9em; margin-right: 0.5em" />
<span>
{node.title}
{node.displayTitle()}
</span>
</span>
{#if expanded}
{#each node.datasets as child (child.title)}
{#each node.datasets as child (child.displayTitle())}
{#if child instanceof DataSet}
<TreeLeafNode {chart} node={child} />
{:else}
Expand Down
2 changes: 1 addition & 1 deletion src/components/tree/TreeLeafNode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
>
<Fa icon={selected ? faEye : faEyeSlash} {color} style="width: 1em; margin-right: 0.5em" />
<span>
{node.title}
{node.displayTitle()}
</span>
</div>

Expand Down
10 changes: 10 additions & 0 deletions src/data/DataSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export default class DataSet {
this.gap = computeGap(data);
}

displayTitle(): string {
// for display to user; use custom title if available, otherwise default to title
return this.customTitle || this.title;
}

randomize(): void {
this.color = getRandomColor();
}
Expand Down Expand Up @@ -108,6 +113,11 @@ export class DataGroup {

constructor(public readonly title: string, public readonly datasets: (DataSet | DataGroup)[]) {}

displayTitle(): string {
// for interface compatibility with `DataSet.displayTitle()`
return this.title;
}

flat(arr: DataSet[]): void {
for (const child of this.datasets) {
if (child instanceof DataSet) {
Expand Down
18 changes: 10 additions & 8 deletions src/deriveLinkDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
importCOVIDcast,
importFluSurv,
importFluView,
importFluViewClinical,
importGFT,
importGHT,
importNIDSSDengue,
Expand Down Expand Up @@ -54,6 +55,7 @@ const lookups = {
covidcast: importCOVIDcast,
flusurv: importFluSurv,
fluview: importFluView,
fluview_clinical: importFluViewClinical,
gft: importGFT,
ght: importGHT,
nidss_dengue: importNIDSSDengue,
Expand All @@ -73,6 +75,7 @@ const argOrders: Record<string, string[]> = {
covid_hosp: ['states', 'issues'],
flusurv: ['locations', 'issues', 'lag'],
fluview: ['regions', 'issues', 'lag', 'auth'],
fluview_clinical: ['regions', 'issues', 'lag'],
gft: ['locations'],
ght: ['auth', 'locations', 'query'],
nidss_dengue: ['locations'],
Expand Down Expand Up @@ -181,12 +184,7 @@ export function initialLoader(datasets: ILinkConfig['datasets']) {

return Promise.all(resolvedDataSets).then((data) => {
const cleaned = data.filter((d): d is DataSet => d != null);
cleaned.forEach((d) => {
if (d.customTitle) {
d.title = d.customTitle;
}
add(d);
});
cleaned.forEach((d) => add(d));
return cleaned;
});
};
Expand Down Expand Up @@ -228,11 +226,15 @@ export function getDirectLinkImpl(state: SharedState): { url: URL; anySkipped: b
let anySkipped = false;
state.active.forEach((data) => {
if (data.params) {
config.datasets.push({
const ds = {
color: data.color,
title: data.title,
params: data.params as unknown as Record<string, unknown>,
});
};
if (data.customTitle) {
ds.params.custom_title = data.customTitle;
}
config.datasets.push(ds);
} else {
console.log('unable to get direct link to dataset:', data.title);
anySkipped = true;
Expand Down