Skip to content

Commit e9c6e2e

Browse files
authored
Merge pull request #1140 from cmu-delphi/sgratzl/quidel-raw-hint
Quidel Raw Hint
2 parents 52430d9 + df6b372 commit e9c6e2e

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

src/blocks/HistoryLineChart.svelte

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,15 @@
274274
275275
$: raw = singleRaw && sensor.rawValue != null && !($isMobileDevice && showFull);
276276
$: regions = raw ? [region.value] : resolveRegions(region.value, singleRegionOnly, showNeighbors);
277-
$: annotations = $annotationManager.getWindowAnnotations(sensor.value, regions, timeFrame.min, timeFrame.max, true);
277+
$: annotations = raw
278+
? $annotationManager.getMultiWindowAnnotations(
279+
[sensor.value, sensor.rawValue],
280+
regions,
281+
timeFrame.min,
282+
timeFrame.max,
283+
true,
284+
)
285+
: $annotationManager.getWindowAnnotations(sensor.value, regions, timeFrame.min, timeFrame.max, true);
278286
$: spec = injectRanges(
279287
genSpec(sensor, region, date, timeFrame, {
280288
height,
@@ -286,7 +294,7 @@
286294
stderr,
287295
}),
288296
timeFrame,
289-
annotations,
297+
annotations.filter((d) => !d.isAllTime),
290298
);
291299
$: data = raw
292300
? loadSingleData(sensor, region, timeFrame)
@@ -336,7 +344,7 @@
336344
<Toggle bind:checked={singleRaw}>Raw Data</Toggle>
337345
{/if}
338346
{#if !($isMobileDevice && raw)}
339-
<Toggle bind:checked={showFull}>Show All Dates</Toggle>
347+
<Toggle bind:checked={showFull}>All Dates</Toggle>
340348
{/if}
341349
<div class="spacer" />
342350
<DownloadMenu {fileName} {vegaRef} {data} {sensor} {raw} {stderr} />

src/components/IndicatorAnnotation.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
export let annotation;
88
</script>
99

10-
<div class="uk-alert uk-alert-{annotation.uncertainty ? 'info' : 'warning'} {className}">
10+
<div class="uk-alert uk-alert-{annotation.uncertainty || annotation.isAllTime ? 'info' : 'warning'} {className}">
1111
<h5 class="alert-header">
1212
<div class="text">
1313
<span class="inline-svg-icon">
@@ -19,7 +19,9 @@
1919
</span>
2020
{annotation.problem}
2121
</div>
22-
<div class="date">{formatDateISO(annotation.dates[0])} - {formatDateISO(annotation.dates[1])}</div>
22+
{#if !annotation.isAllTime}
23+
<div class="date">{formatDateISO(annotation.dates[0])} - {formatDateISO(annotation.dates[1])}</div>
24+
{/if}
2325
</h5>
2426
<p class="uk-margin-remove-bottom">
2527
{annotation.explanation}

src/data/annotations.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ function parseSignals(signals: string) {
1919
);
2020
}
2121

22+
const ALL_TIME_MIN = new Date(2019, 0, 1);
23+
2224
function parseDates(dates: string): [Date, Date] {
2325
if (!dates) {
24-
return [new Date(), new Date()];
26+
return [ALL_TIME_MIN, new Date()];
2527
}
2628
if (/^-\d+$/g.test(dates)) {
2729
const uncertaintyDays = Number.parseInt(dates);
@@ -73,6 +75,7 @@ export class Annotation {
7375
readonly regions: { level: RegionLevel; ids: '*' | Set<string> }[];
7476
readonly uncertainty: boolean;
7577
readonly reference?: string;
78+
readonly isAllTime: boolean;
7679

7780
constructor(raw: EpiDataAnomaliesRow) {
7881
this.source = raw.source.trim();
@@ -83,6 +86,7 @@ export class Annotation {
8386
this.regions = parseRegions(raw.regions);
8487
this.reference = raw.reference;
8588
this.uncertainty = /^-\d+$/g.test(raw.dates);
89+
this.isAllTime = !raw.dates;
8690
}
8791

8892
/**
@@ -191,6 +195,25 @@ export class AnnotationManager {
191195
.sort(sortByDate);
192196
}
193197

198+
getMultiWindowAnnotations(
199+
sensors: { id: string; signal: string }[],
200+
region: RegionInfo | RegionInfo[],
201+
dateStart: Date,
202+
dateEnd: Date,
203+
includeUncertainty = false,
204+
): Annotation[] {
205+
return this.annotations
206+
.filter(
207+
(d) =>
208+
sensors.some((s) => d.matchSensor(s)) &&
209+
region != null &&
210+
d.matchRegion(region) &&
211+
d.inDateRange(dateStart, dateEnd) &&
212+
(includeUncertainty || !d.uncertainty),
213+
)
214+
.sort(sortByDate);
215+
}
216+
194217
getWindowLevelAnnotations(
195218
sensor: { id: string; signal: string },
196219
level: RegionLevel,

0 commit comments

Comments
 (0)