Skip to content

Commit d2b9851

Browse files
committed
fixed bugs for release
1 parent 9263d8a commit d2b9851

File tree

5 files changed

+36
-30
lines changed

5 files changed

+36
-30
lines changed

src/App.svelte

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,11 @@
413413
}
414414
415415
.graph-container {
416-
position: absolute;
416+
position: relative;
417+
float: right;
418+
width: 410px;
417419
z-index: 1001;
418-
bottom: 0px;
420+
bottom: 382px;
419421
right: 10px;
420422
background-color: rgba(255, 255, 255, 0.9);
421423
padding: 5px 5px;
@@ -458,9 +460,10 @@
458460
}
459461
460462
.graph-toggole-button-container {
461-
position: absolute;
463+
position: relative;
464+
float: right;
462465
z-index: 1001;
463-
bottom: 0px;
466+
bottom: 60px;
464467
right: 10px;
465468
background-color: rgba(255, 255, 255, 0.9);
466469
padding: 5px 5px;
@@ -520,9 +523,10 @@
520523
}
521524
522525
.time-container {
523-
position: absolute;
524-
bottom: 0px;
526+
position: relative;
527+
bottom: 10px;
525528
left: 10px;
529+
width: 660px;
526530
z-index: 1002;
527531
background-color: rgba(255, 255, 255, 0.9);
528532
padding: 30px 10px;

src/Graph.svelte

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@
156156
157157
let currDate = parseTime(date);
158158
let currDateSeven = d3.timeDay.offset(currDate, -7);
159-
160159
// peg values to max and min if out of range
161160
let minMax = calculateSD(sensor);
162161
let chartMax = minMax[1];
@@ -195,12 +194,15 @@
195194
let format = $sensorMap.get(sensor).format;
196195
if (format === 'percent') formatYTicks = d => d + '%';
197196
else if (format === 'raw') {
198-
if (sensor.match(/num/)) {
199-
//formatYTicks = d3.format('d');
200-
formatYTicks = y.domain[1] - y.domain[0] > 10 ? d3.format('.0f') : d3.format('.2f');
197+
const range = y.domain()[1] - y.domain()[0];
198+
if (range > 10) {
199+
formatYTicks = d3.format('.0f');
200+
} else if (range < 1) {
201+
formatYTicks = d3.format('.2f');
201202
} else {
202-
formatYTicks = y.domain[1] - y.domain[0] > 10 ? d3.format('.0f') : d3.format('.1f');
203+
formatYTicks = d3.format('.1f');
203204
}
205+
//formatYTicks = y.domain[1] - y.domain[0] > 10 ? d3.format('.0f') : d3.format('.1f');
204206
}
205207
var formatXTicks = data.length < 6 ? d3.timeDay.every(1) : d3.timeDay.every(4);
206208

src/Legend.svelte

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
sts = stats.get(sens + '_' + level);
2828
valueMinMax = [sts.mean - 3 * sts.std, sts.mean + 3 * sts.std];
2929
30-
high = valueMinMax[1].toFixed(2);
31-
low = Math.max(0, valueMinMax[0]).toFixed(2);
30+
high = sig_figs(valueMinMax[1].toFixed(2), 3);
31+
low = sig_figs(Math.max(0, valueMinMax[0]).toFixed(2), 3);
3232
3333
logColorArr = [{ label: '0', from_color: DIRECTION_THEME.countMin, to_color: DIRECTION_THEME.countMin }];
3434
var max = Math.log(valueMinMax[1]) / Math.log(10);
@@ -49,12 +49,12 @@
4949
sts = stats.get(sens);
5050
valueMinMax = [sts.mean - 3 * sts.std, sts.mean + 3 * sts.std];
5151
if ($sensorMap.get($currentSensor).format === 'raw') {
52-
high = valueMinMax[1].toFixed(2);
53-
low = Math.max(0, valueMinMax[0]).toFixed(2);
52+
high = sig_figs(valueMinMax[1].toFixed(2), 3);
53+
low = sig_figs(Math.max(0, valueMinMax[0]).toFixed(2), 3);
5454
valueMinMax[0] = Math.max(0, valueMinMax[0]);
5555
} else {
56-
high = Math.min(100, valueMinMax[1]).toFixed(2) + '% ';
57-
low = Math.max(0, valueMinMax[0]).toFixed(2) + '% ';
56+
high = sig_figs(Math.min(100, valueMinMax[1]).toFixed(2), 3) + '% ';
57+
low = sig_figs(Math.max(0, valueMinMax[0]).toFixed(2), 3) + '% ';
5858
valueMinMax[1] = Math.min(100, valueMinMax[1]);
5959
}
6060
const colorScaleLinear = d3.scaleSequential(d3.interpolateYlOrRd).domain([valueMinMax[0], valueMinMax[1]]);
@@ -72,7 +72,7 @@
7272
}
7373
7474
function sig_figs(value, sigFigs) {
75-
return parseFloat(value).toPrecision(sigFigs);
75+
return parseFloat(parseFloat(value).toPrecision(sigFigs));
7676
}
7777
</script>
7878

@@ -171,7 +171,7 @@
171171
{:else if $currentSensor.match(/num/)}
172172
<div class="tick-p">
173173
<div class="tick" style="background: black" />
174-
<p>{high ? sig_figs(high, 3) + '+' : ''}</p>
174+
<p>{high ? high + '+' : ''}</p>
175175
</div>
176176
{#each logColorArr as { label, from_color, to_color }, i}
177177
<div class="count-p">
@@ -185,15 +185,15 @@
185185
{:else}
186186
<div class="tick-p">
187187
<div class="tick" style="background: black" />
188-
<p>{high ? sig_figs(high, 3) + '+' : ''}</p>
188+
<p>{high ? high + '+' : ''}</p>
189189
</div>
190190
<div
191191
class="legend-bar"
192192
style="background: linear-gradient(to top, {linColorArr[0]}, {linColorArr[1]}, {linColorArr[2]}, {linColorArr[3]},
193193
{linColorArr[4]})" />
194194
<div class="tick-p">
195195
<div class="tick" style="background: black" />
196-
<p>{sig_figs(low, 3)}</p>
196+
<p>{low}</p>
197197
</div>
198198
{/if}
199199
</div>

src/Options.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
currentSensor.set(sensor);
221221
shouldDisplayBanner = true;
222222
}}>
223-
<optgroup label="Indicators">
223+
<optgroup label="Indicator">
224224
{#each Array.from($sensorMap.keys()).filter(d => !$sensorMap.get(d).official) as sensor}
225225
<option title={$sensorMap.get(sensor).tooltipText} value={sensor}>{$sensorMap.get(sensor).name}</option>
226226
{/each}

src/stores.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,23 @@ export const sensors = readable(
5454
official: false,
5555
},
5656
{
57-
name: 'Full-time work (Safegraph)',
57+
name: 'Away from home 6hr+ (SG)',
5858
id: 'safegraph',
59-
tooltipText: 'Proportion of people working full time, based on Safegraph mobility data',
60-
mapTitleText: 'Proportion of people working full time, based on Safegraph mobility data',
61-
chartTitleText: 'Proportion of people working full time, based on Safegraph mobility data',
59+
tooltipText: 'Proportion of people spending 6 hours or more away from home, based on SafeGraph mobility data',
60+
mapTitleText: 'Proportion of people spending 6 hours or more away from home, based on SafeGraph mobility data',
61+
chartTitleText: 'Proportion of people spending 6 hours or more away from home, based on SafeGraph mobility data',
6262
yAxis: 'Proportion',
6363
format: 'raw',
6464
signal: 'full_time_work_prop',
6565
levels: ['county', 'state'],
6666
official: false,
6767
},
6868
{
69-
name: 'Part-time work (Safegraph)',
69+
name: 'Away from home 3-6hr (SG)',
7070
id: 'safegraph',
71-
tooltipText: 'Proportion of people working part time, based on Safegraph mobility data',
72-
mapTitleText: 'Proportion of people working part time, based on Safegraph mobility data',
73-
chartTitleText: 'Proportion of people working part time, based on Safegraph mobility data',
71+
tooltipText: 'Proportion of people spending 3-6 hours away from home, based on SafeGraph mobility data',
72+
mapTitleText: 'Proportion of people spending 3-6 hours away from home, based on SafeGraph mobility data',
73+
chartTitleText: 'Proportion of people spending 3-6 hours away from home, based on SafeGraph mobility data',
7474
yAxis: 'Proportion',
7575
format: 'raw',
7676
signal: 'part_time_work_prop',

0 commit comments

Comments
 (0)