Skip to content

Commit 9ef294b

Browse files
committed
Merge remote-tracking branch 'origin/dev' into sgratzl/annotationlog
2 parents 3d21ee8 + 6a2e4fd commit 9ef294b

File tree

5 files changed

+62
-43
lines changed

5 files changed

+62
-43
lines changed

src/modes/mobile/HistoryLineChart.svelte

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
*/
5454
export let ends = null;
5555
56+
export let expandableWindow = false;
57+
58+
let showFull = false;
59+
5660
/**
5761
* @type {import("../../stores/params").Region}
5862
*/
@@ -66,18 +70,19 @@
6670
};
6771
6872
$: highlightDate = date.value;
73+
$: timeFrame = showFull && expandableWindow ? date.sensorTimeFrame : date.windowTimeFrame;
6974
7075
/**
7176
* @param {import('../../stores/params').SensorParam} sensor
7277
* @param {import('../../stores/params').RegionParam} region
7378
* @param {import('../../stores/params').DateParam} date
7479
*/
75-
function genSpec(sensor, region, date, height, zero, singleRaw, isMobile) {
80+
function genSpec(sensor, region, date, timeFrame, height, zero, singleRaw, isMobile) {
7681
const options = {
7782
initialDate: highlightDate || date.value,
7883
height,
7984
color: MULTI_COLORS[0],
80-
domain: date.windowTimeFrame.domain,
85+
domain: timeFrame.domain,
8186
zero,
8287
xTitle: sensor.xAxis,
8388
title: [sensor.name, `in ${region.displayName}`],
@@ -111,26 +116,26 @@
111116
* @param {import("../../stores/params").DateParam} date
112117
* @param {import("../../stores/params").RegionParam} region
113118
*/
114-
function loadData(sensor, region, date) {
115-
if (!region.value || !date.value) {
119+
function loadData(sensor, region, timeFrame) {
120+
if (!region.value) {
116121
return null;
117122
}
118-
const selfData = fetcher.fetch1Sensor1RegionNDates(sensor, region, date.windowTimeFrame);
123+
const selfData = fetcher.fetch1Sensor1RegionNDates(sensor, region, timeFrame);
119124
120125
const data = [selfData];
121126
122127
if (region.level === 'county') {
123128
const state = getInfoByName(region.state);
124-
const stateData = fetcher.fetch1Sensor1RegionNDates(sensor, state, date.windowTimeFrame);
129+
const stateData = fetcher.fetch1Sensor1RegionNDates(sensor, state, timeFrame);
125130
const relatedCounties = getRelatedCounties(region.value);
126131
const relatedData = fetcher
127-
.fetch1SensorNRegionsNDates(sensor, relatedCounties, date.windowTimeFrame)
132+
.fetch1SensorNRegionsNDates(sensor, relatedCounties, timeFrame)
128133
.then((r) => averageByDate(r, sensor, neighboringInfo))
129134
.then((r) => addMissing(r, sensor));
130135
data.push(relatedData, stateData);
131136
}
132137
if (region.level !== 'nation') {
133-
data.push(fetcher.fetch1Sensor1RegionNDates(sensor, nationInfo, date.windowTimeFrame));
138+
data.push(fetcher.fetch1Sensor1RegionNDates(sensor, nationInfo, timeFrame));
134139
}
135140
return Promise.all(data).then((rows) => rows.reverse().flat());
136141
}
@@ -140,12 +145,12 @@
140145
* @param {import("../../stores/params").DateParam} date
141146
* @param {import("../../stores/params").RegionParam} region
142147
*/
143-
function loadSingleData(sensor, region, date) {
144-
if (!region.value || !date.value) {
148+
function loadSingleData(sensor, region, timeFrame) {
149+
if (!region.value) {
145150
return null;
146151
}
147-
const selfData = fetcher.fetch1Sensor1RegionNDates(sensor, region, date.windowTimeFrame);
148-
const rawData = fetcher.fetch1Sensor1RegionNDates(sensor.rawValue, region, date.windowTimeFrame);
152+
const selfData = fetcher.fetch1Sensor1RegionNDates(sensor, region, timeFrame);
153+
const rawData = fetcher.fetch1Sensor1RegionNDates(sensor.rawValue, region, timeFrame);
149154
150155
return Promise.all([selfData, rawData]).then((data) => {
151156
return combineSignals(data, data[0], ['smoothed', 'raw']);
@@ -174,28 +179,25 @@
174179
/**
175180
* @param {import("../../stores/params").SensorParam} sensor
176181
* @param {import("../../stores/params").Region[]} region
177-
* @param {import("../../stores/params").DateParam} date
178182
*/
179-
function generateFileName(sensor, regions, date, raw) {
183+
function generateFileName(sensor, regions, timeFrame, raw) {
180184
const regionName = regions.map((region) => `${region.propertyId}-${region.displayName}`).join(',');
181185
let suffix = '';
182186
if (raw) {
183187
suffix = '_RawVsSmoothed';
184188
}
185-
return `${sensor.name}_${regionName}_${formatDateISO(date.windowTimeFrame.min)}-${formatDateISO(
186-
date.windowTimeFrame.max,
187-
)}${suffix}`;
189+
return `${sensor.name}_${regionName}_${formatDateISO(timeFrame.min)}-${formatDateISO(timeFrame.max)}${suffix}`;
188190
}
189191
190-
function injectRanges(spec, date, annotations) {
192+
function injectRanges(spec, timeFrame, annotations) {
191193
if (annotations.length > 0) {
192-
spec.layer.unshift(genAnnotationLayer(annotations, date.windowTimeFrame));
194+
spec.layer.unshift(genAnnotationLayer(annotations, timeFrame));
193195
}
194-
if (starts && starts > date.windowTimeFrame.min) {
195-
spec.layer.unshift(genDateHighlight(starts > date.windowTimeFrame.max ? date.windowTimeFrame.max : starts));
196+
if (starts && starts > timeFrame.min) {
197+
spec.layer.unshift(genDateHighlight(starts > timeFrame.max ? timeFrame.max : starts));
196198
}
197-
if (ends && ends < date.windowTimeFrame.max) {
198-
spec.layer.unshift(genDateHighlight(ends < date.windowTimeFrame.min ? date.windowTimeFrame.min : ends));
199+
if (ends && ends < timeFrame.max) {
200+
spec.layer.unshift(genDateHighlight(ends < timeFrame.min ? timeFrame.min : ends));
199201
}
200202
return spec;
201203
}
@@ -204,16 +206,15 @@
204206
let singleRaw = false;
205207
206208
$: regions = raw ? [region.value] : resolveRegions(region.value);
207-
$: annotations = $annotationManager.getWindowAnnotations(
208-
sensor.value,
209-
regions,
210-
date.windowTimeFrame.min,
211-
date.windowTimeFrame.max,
212-
);
209+
$: annotations = $annotationManager.getWindowAnnotations(sensor.value, regions, timeFrame.min, timeFrame.max);
213210
$: raw = singleRaw && sensor.rawValue != null;
214-
$: spec = injectRanges(genSpec(sensor, region, date, height, !zoom, raw, $isMobileDevice), date, annotations);
215-
$: data = raw ? loadSingleData(sensor, region, date) : loadData(sensor, region, date);
216-
$: fileName = generateFileName(sensor, regions, date, raw);
211+
$: spec = injectRanges(
212+
genSpec(sensor, region, date, timeFrame, height, !zoom, raw, $isMobileDevice),
213+
timeFrame,
214+
annotations,
215+
);
216+
$: data = raw ? loadSingleData(sensor, region, timeFrame) : loadData(sensor, region, timeFrame);
217+
$: fileName = generateFileName(sensor, regions, timeFrame, raw);
217218
218219
function findValue(region, data, date, prop = 'value') {
219220
if (!date) {
@@ -243,7 +244,7 @@
243244

244245
<Vega
245246
bind:this={vegaRef}
246-
{className}
247+
className="{className} {showFull && expandableWindow ? 'chart-breakout' : ''}"
247248
{spec}
248249
{data}
249250
tooltip={HistoryLineTooltip}
@@ -258,6 +259,9 @@
258259
{#if sensor.rawValue != null}
259260
<Toggle bind:checked={singleRaw}>Raw Data</Toggle>
260261
{/if}
262+
{#if expandableWindow}
263+
<Toggle bind:checked={showFull}>Show All Dates</Toggle>
264+
{/if}
261265
<div class="spacer" />
262266
<DownloadMenu {fileName} {vegaRef} {data} {sensor} {raw} />
263267
</div>

src/modes/mobile/MobileIndicatorOverview.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<hr />
6868
<FancyHeader invert sub="Chart" anchor="chart">{sensor.name}</FancyHeader>
6969
<div class="chart-300">
70-
<HistoryLineChart {sensor} {date} {region} {fetcher} />
70+
<HistoryLineChart {sensor} {date} {region} {fetcher} expandableWindow />
7171
</div>
7272
</div>
7373
</div>

src/modes/mobile/MobileOverview.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<hr />
5050
<FancyHeader invert sub="Chart" anchor="chart">{CASES.name}</FancyHeader>
5151
<div class="chart-300">
52-
<HistoryLineChart sensor={CASES} {date} {region} {fetcher} />
52+
<HistoryLineChart sensor={CASES} {date} {region} {fetcher} expandableWindow />
5353
</div>
5454
<hr />
5555
<AllIndicatorOverview {date} {region} {fetcher} />

src/modes/mobile/common.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,21 @@
235235
height: 100%;
236236
}
237237

238+
.chart-breakout.vega-embed,
239+
.chart-breakout > .vega-embed {
240+
--max-width: 95vw;
241+
/* breakout the chart up to 80vw */
242+
width: max(100%, var(--max-width));
243+
margin-left: calc(-0.5 * var(--max-width) + 50%);
244+
}
245+
246+
@media only screen and (min-width: 1600px) {
247+
.chart-breakout.vega-embed,
248+
.chart-breakout > .vega-embed {
249+
--max-width: 80vw;
250+
}
251+
}
252+
238253
.mobile-map > canvas {
239254
border: 1px solid #f0f1f3;
240255
border-radius: 3px;

src/stores/descriptions.raw.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Id: safegraph
3131
Signal: part_time_work_prop_7dav
3232
RawSignal: part_time_work_prop
3333
Type: public
34-
Levels: [county, state, nation]
34+
Levels: [county, state, hhs, nation]
3535
XAxis: Date
3636
YAxis: Fraction of population
3737
Format: fraction
@@ -58,7 +58,7 @@ Name: Bar Visits
5858
Id: safegraph
5959
Signal: bars_visit_prop
6060
Type: public
61-
Levels: [county, msa, state, hrr, nation]
61+
Levels: [county, msa, state, hhs, hrr, nation]
6262
XAxis: Date
6363
YAxis: Visits per 100,000 people
6464
Format: per100k
@@ -81,7 +81,7 @@ Name: Restaurant Visits
8181
Id: safegraph
8282
Signal: restaurants_visit_prop
8383
Type: public
84-
Levels: [county, msa, state, hrr, nation]
84+
Levels: [county, msa, state, hhs, hrr, nation]
8585
XAxis: Date
8686
YAxis: Visits per 100,000 people
8787
Format: per100k
@@ -165,7 +165,7 @@ Id: google-symptoms
165165
Signal: sum_anosmia_ageusia_smoothed_search
166166
RawSignal: sum_anosmia_ageusia_raw_search
167167
Type: public
168-
Levels: [state, msa, hrr, county]
168+
Levels: [state, msa, hrr, county, hhs, nation]
169169
XAxis: Date
170170
YAxis: Scaled search volume (arbitrary scale)
171171
Format: raw
@@ -189,7 +189,7 @@ Id: doctor-visits
189189
Signal: smoothed_adj_cli
190190
RawSignal: null
191191
Type: early
192-
Levels: [county, msa, state, hrr]
192+
Levels: [county, msa, state, hrr, hhs, nation]
193193
XAxis: Date
194194
YAxis: Percentage
195195
Format: percent
@@ -303,7 +303,7 @@ Id: hospital-admissions
303303
Signal: smoothed_adj_covid19_from_claims
304304
RawSignal: null
305305
Type: late
306-
Levels: [county, msa, state, hrr, nation]
306+
Levels: [county, msa, state, hrr, hhs, nation]
307307
XAxis: Date
308308
YAxis: Percentage
309309
Format: percent
@@ -340,7 +340,7 @@ CasesOrDeathSignals:
340340

341341

342342
Type: late
343-
Levels: [msa, county, state, hrr, nation]
343+
Levels: [msa, county, state, hrr, hhs, nation]
344344
XAxis: Reported Date
345345
YAxis: Cases
346346
Format: per100k
@@ -383,7 +383,7 @@ CasesOrDeathSignals:
383383

384384

385385
Type: late
386-
Levels: [msa, county, state, hrr, nation]
386+
Levels: [msa, county, state, hrr, hhs, nation]
387387
XAxis: Reported Date
388388
YAxis: Deaths
389389
Format: per100k

0 commit comments

Comments
 (0)