File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 8
8
import { onMount } from ' svelte' ;
9
9
import { trackEvent } from ' ../../stores/ga' ;
10
10
import Search from ' ../../components/Search.svelte' ;
11
- import { infosByLevel } from ' ../../maps' ;
11
+ import { getCountiesOfState , infosByLevel } from ' ../../maps' ;
12
12
import { formatDateISO } from ' ../../formats' ;
13
13
import { questionCategories , refSensor } from ' ../../modes/survey/questions' ;
14
14
import { CASES_DEATH_SOURCE , getDataSource } from ' ../../stores/dataSourceLookup' ;
59
59
60
60
let geoValuesMode = ' all' ;
61
61
let geoValues = [];
62
- $: geoItems = infosByLevel[geoType] || [];
62
+ $: geoItems = [ ... infosByLevel[geoType] || [], ... (geoType === ' county ' ? infosByLevel . state : []) ];
63
63
$: {
64
64
if (geoItems != null ) {
65
65
geoValues = [];
66
66
geoValuesMode = guessMode (geoItems .length );
67
67
}
68
68
}
69
+ function flatIds (geoValues ) {
70
+ if (geoType === ' county' ) {
71
+ // flatten states to its counties
72
+ return geoValues .map ((d ) => d .level === ' state' ? getCountiesOfState (d).map ((d ) => d .propertyId ) : d .propertyId ).flat ();
73
+ } else {
74
+ return geoValues .map ((d ) => d .propertyId );
75
+ }
76
+ }
69
77
$: isAllRegions = geoValuesMode === ' all' || geoValues .length === 0 ;
70
- $: geoIDs = geoValues . map (( d ) => d . propertyId );
78
+ $: geoIDs = flatIds (geoValues );
71
79
72
80
let asOfMode = ' latest' ;
73
81
let asOfDate = new Date ();
You can’t perform that action at this time.
0 commit comments