File tree Expand file tree Collapse file tree 7 files changed +49
-9
lines changed Expand file tree Collapse file tree 7 files changed +49
-9
lines changed Original file line number Diff line number Diff line change 418
418
<Toggle bind:checked ={singleRaw }>Raw Data</Toggle >
419
419
{/if }
420
420
<div class =" spacer" />
421
- <DownloadMenu {fileName } {vegaRef } {data } {sensor } {raw } {stderr } />
421
+ <DownloadMenu {fileName } {vegaRef } {data } {date } { region } { sensor } {raw } {stderr } />
422
422
</div >
423
423
424
424
{#if showAgeStratifications }
Original file line number Diff line number Diff line change 61
61
<DownloadMenu
62
62
{vegaRef }
63
63
{data }
64
+ {date }
65
+ {region }
64
66
{sensor }
65
67
absolutePos
66
68
fileName =" {sensor .name }_US Counties_ {formatDateISO (date .value )}"
Original file line number Diff line number Diff line change 153
153
<div >Hex fill color: value at selected date</div >
154
154
</div >
155
155
<ColorLegend {sensor } level ="state" gradientLength ={$isMobileDevice ? 250 : 280 }>
156
- <DownloadMenu fileName =" {sensor .name }_US_States_ {formatDateISO (date .value )}" data ={dumpData } absolutePos {sensor } />
156
+ <DownloadMenu
157
+ fileName =" {sensor .name }_US_States_ {formatDateISO (date .value )}"
158
+ data ={dumpData }
159
+ absolutePos
160
+ {date }
161
+ {region }
162
+ {sensor }
163
+ />
157
164
</ColorLegend >
158
165
</div >
159
166
Original file line number Diff line number Diff line change 118
118
on:click ={onClickHandler }
119
119
eventListeners ={[' click' ]}
120
120
/>
121
- <DownloadMenu {vegaRef } {data } {sensor } absolutePos {fileName } />
121
+ <DownloadMenu {vegaRef } {data } {date } { region } { sensor } absolutePos {fileName } />
122
122
</div >
123
123
</FullWidthWrapper >
124
124
Original file line number Diff line number Diff line change 1
1
<script >
2
- import { downloadUrl , scrollToTop } from ' ../util' ;
2
+ import { downloadUrl } from ' ../util' ;
3
3
import { csvFormat } from ' d3-dsv' ;
4
4
import { formatDateISO } from ' ../formats' ;
5
5
import { modeByID } from ' ../modes' ;
13
13
14
14
export let data = null ;
15
15
16
+ /**
17
+ * @type {import("../stores/params").DateParam}
18
+ */
19
+ export let date = null ;
20
+ /**
21
+ * @type {import("../stores/params").RegionParam}
22
+ */
23
+ export let region = null ;
16
24
/**
17
25
* @type {import("../stores/params").SensorParam}
18
26
*/
112
120
function exportData () {
113
121
// switch to export mode
114
122
currentMode .set (modeByID .export );
115
- sensor .set (sensor .value , true );
116
- scrollToTop ();
123
+ }
124
+
125
+ let exportURL = ' ' ;
126
+ $: {
127
+ exportURL = ' ' ;
128
+ if (sensor && sensor .key .split (' -' ).length >= 2 ) {
129
+ // Given a sensor key formatted "sensor-name-here-signal_name_here", split on the last dash
130
+ let [last, ... rest] = sensor .key .split (' -' ).reverse ();
131
+ rest = rest .reverse ().join (' -' );
132
+ exportURL += ` data_source=${ rest} &signal=${ last} ` ;
133
+
134
+ if (region) {
135
+ exportURL += ` &geo_type=${ region .level } &geo_value=${ region .propertyId } ` ;
136
+ }
137
+ if (date) {
138
+ exportURL += ` &start_day=${ formatDateISO (date .value )} &end_day=${ formatDateISO (date .value )} ` ;
139
+ }
140
+ }
117
141
}
118
142
</script >
119
143
140
164
{#if advanced }
141
165
<li class =" uk-nav-divider" />
142
166
<li >
143
- <a href =" ../ {modeByID .export .id }" on:click | preventDefault ={exportData }>Advanced Data Export</a >
167
+ <a href ={ ` ../$ {modeByID .export .id }/?${ exportURL } ` } on:click ={exportData }>Advanced Data Export</a >
144
168
</li >
145
169
{/if }
146
170
</ul >
Original file line number Diff line number Diff line change 182
182
183
183
<div class =" uk-position-relative" >
184
184
<FancyHeader anchor ="table" >{title .title }</FancyHeader >
185
- <DownloadMenu {fileName } data ={loadedData } absolutePos prepareRow ={(row ) => row .dump } />
185
+ <DownloadMenu {fileName } data ={loadedData } absolutePos prepareRow ={(row ) => row .dump } { date } { region } { sensor } />
186
186
<p class =" uk-text-center uk-text-italic ux-hint" >
187
187
<span class =" inline-svg-icon" >
188
188
{@html mousePointerIcon }
Original file line number Diff line number Diff line change 1
1
<script >
2
+ import { modeByID } from ' ..' ;
3
+ import { currentMode } from ' ../../stores' ;
2
4
import { formatDateISO } from ' ../../formats' ;
3
5
import AboutSection from ' ../../components/AboutSection.svelte' ;
4
6
15
17
*/
16
18
export let sensor;
17
19
20
+ function exportData () {
21
+ // switch to export mode
22
+ currentMode .set (modeByID .export );
23
+ }
24
+
18
25
let exportURL = ' ' ;
19
26
$: {
20
27
exportURL = ' ' ;
52
59
</li >
53
60
{/each }
54
61
<li >
55
- <a href ={` ../export/?${exportURL } ` }>Export Data</a >
62
+ <a href ={` ../${ modeByID . export . id } /?${exportURL } ` } on:click ={ exportData }>Export Data</a >
56
63
</li >
57
64
</ul >
58
65
{/if }
You can’t perform that action at this time.
0 commit comments