-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
2472 lines (1889 loc) · 74.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-VFFFF32C72"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-VFFFF32C72');
</script>
<meta charset="UTF-8">
<title>COVID-19 Map</title>
</head>
<body>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin=""/>
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"
integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
crossorigin=""></script>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-ajax/2.1.0/leaflet.ajax.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>
<script src="moment.js"></script>
<script type='text/javascript' src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="echarts.min.js"></script>
<style>
.ui-slider-tick-mark{
display:inline-block;
width:1px;
background:black;
height:2px;
position:absolute;
left:-2 px;
top: 4.5px;
}
#slider label {
position: absolute;
width: 20px;
margin-top: 20px;
margin-left: -10px;
text-align: center;
}
body {
padding: 0;
margin: 0;
}
#mapid {
height: 100%;
width: 100%;
}
#title{
margin-bottom: 20px;
}
#metric_input{
padding-left: 20px;
padding-top: 10px;
padding-bottom: 10px;
padding-right: 10px;
}
.info {
padding: 6px 8px;
font: 14px/16px Arial, Helvetica, sans-serif;
background: white;
background: rgba(255,255,255,0.8);
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
}
.info h4 {
margin: 0 0 5px;
color: #777;
}
.legend {
line-height: 18px;
color: #555;
}
.legend i {
width: 18px;
height: 18px;
float: left;
margin-right: 8px;
opacity: 0.7;
}
.legend_title{
display: block;
text-align: center;
margin-bottom: -15px;
}
.leaflet-control-layers-base > label{
margin-bottom: 0px !important;
}
#slider {
font: 14px/16px Arial, Helvetica, sans-serif;
background: white;
background: rgba(255,255,255,0.8);
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
width: 500px;
margin-left: 50px;
margin-bottom: 50px;
}
#play{
bottom: 8px;
}
.tooltip_custom {
position: absolute;
display: block;
padding: 5px;
font-size: 11px;
visibility: visible;
margin-top: -2px;
bottom:100%;
margin-left: -3.2em;
}
.tooltip .tooltip-arrow {
bottom: 0;
left: 50%;
margin-left: -5px;
border-top: 5px solid #000000;
border-right: 5px solid transparent;
border-left: 5px solid transparent;
position: absolute;
width: 0;
height: 0;
}
.tooltip-inner {
max-width: 200px;
padding: 2px 6px;
color: black;
text-align: center;
text-decoration: none;
font: 14px/16px Arial, Helvetica, sans-serif;
background-color: rgba(255,255,255,0.8);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.ui-slider .ui-slider-handle:focus { outline: 1px dotted gray; }
.block {
display: block;
}
.myButtonBar {
padding: 10px 10px 4px 6px;
font: 14px/16px Arial, Helvetica, sans-serif;
background: white;
background: rgba(255,255,255,0.8);
box-shadow: 0 0 15px rgba(0,0,0,0.2);
border-radius: 5px;
}
.block > input{
margin-right: 5px;
}
#slider > label {
width: 90px;
margin-left: -40px;
color: black;
text-align: center;
text-decoration: none;
font: 14px/16px Arial, Helvetica, sans-serif;
background-color: rgba(255,255,255,0.8);
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
fieldset {
border: none !important;
}
#x {
position: absolute;
top: 0px;
right: 0px;
z-index: 1;
}
#Btn2{
position: absolute;
top: 50%;
right: 0;
margin-right: 0;
transform: rotate(-90deg);
transform-origin-y: -41px;
z-index: 1000;
font-size: 1em;
transition: 0.1s;
}
@media screen and(-webkit-min-device-pixel-ratio:0) {
#Btn2 {-chrome-:only(;
-webkit-transform-origin-y: -46px;
);}
}
@media screen and (-webkit-min-device-pixel-ratio:0)
and (min-resolution:.001dpcm) {
#Btn2{
-webkit-transform-origin-y: -46px;
}
}
.sidebar {
height: 100%;
width: 0;
position: fixed;
z-index: 1000;
top: 0;
right: 0;
overflow-x: hidden;
padding-top: 60px;
transition: 0.1s;
background-color: rgba(255,255,255,0.95) !important;
}
.sidebar .closebtn {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
transition: 0.1s;
background-color: rgba(255,255,255,0.95) !important;
}
.sidebar .closebtn {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}
.sidebar_txt{
margin-left: 10%;
margin-right: 10%;
font-family: Arial, Helvetica, sans-serif;
margin-bottom: 100px;
}
</style>
<div id="mapid"></div>
<input type="button" id="Btn2" value="About the Project" onclick="openNav()" class="btnStyle span3 " />
<div id="mySidebar" class="sidebar">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<div class = 'sidebar_txt'>
<h2>Welcome to the BigMap COVID-19 Tracking Project!</h2>
<p>This is a constantly evolving product and is meant to be "unfinished" in that we will constantly be making improvements as we think of - and have time to implement - them. Given the time-sensitive nature of the COVID-19 pandemic, we wanted to get our analysis "out there" as quickly as possible while maintaining the quality we would expect from other high-quality data science projects.</p>
<h2>Functionality</h2>
<p>The basic functionality of the map includes:</p>
<ul>
<li>Change the metric used to color the map with the radio buttons in the top right</li>
<li>Select a date using the slider on the bottom right</li>
<li>"Play" the historical data, showing how the map changes over time by clicking the button to the left of the time slider</li>
<li>Hover over a county to get the name and current value of the selected metric</li>
<li>Click on a county to show a timeseries plot of the selected metric in that county</li>
</ul>
<h2>Metrics</h2>
<ul>
<li><strong>Case Count</strong> - The number of reported COVID-19 Cases</li>
<li><strong>% Increase</strong> - Percent increase of COVID-19 cases from the previous day</li>
<li><strong>Deaths</strong> - The number of reported COVID-19 Deaths</li>
<li><strong>Doubling</strong> - The number of days since there were half as many COVID-19 cases as the current day. <p>Note, some other projects calculate this value using the current trajectory of the disease in a location, but we have opted for a simpler metric that is more interpretable. Our approach is more of a retrospective look on how a county is doing currently relative to the recent past.</p></li>
<li><strong>R(t)</strong> - The effective reproduction number
<p>As per Thompson et al. (2019): "R(t) represents the expected number of secondary cases arising from a primary case infected at time t. This value changes throughout an outbreak. If the value of R(t) is and remains below one, the outbreak will die out. However, while R(t) is larger than one, a sustained outbreak is likely. The aim of control interventions is typically to reduce the reproduction number below one."</p>
<p>Because R(t) is sensitive to reporting abnormalities that may occur day-to-day, we provide smoothed metrics for 3- and 7-day time scales.</p>
<p>For more details on the R(t) metric used in this project, see <a href = 'https://github.com/nick3703/Parametric-Modeling-for-Time-Varying-Reproducibility-Number'>Nick Clark's Git Repo</a></p>
</li>
<li><strong>Infectious Probability</strong> - The probability that someone on the street is infectious
<p>This probability is calculated by dividing the number of people who have COVID-19 (but are not hospitalized) by a county's total population. The number of non-hospitalized people with COVID-19 is based on the following assumptions:</p>
<ul>
<li>Number of days between symptoms and getting a positive test result = 2 days (source: https://www.labcorp.com/tests/139900/2019-novel-coronavirus-covid-19-naa)</li>
<li>Number of days infectious after showing symptoms = 10 days (source: https://www.medrxiv.org/content/10.1101/2020.03.05.20030502v1)</li>
<li>Number of days between symptoms and hospitalization (if hospitalized) = 7 (source: https://jamanetwork.com/journals/jama/fullarticle/2761044)</li>
<li>Undetected cases (i.e., amount of people who likely have the virus and are not captured in the positive testing numbers) = 10x (source: https://science.sciencemag.org/content/368/6490/489)</li>
<li>Hospitalization rates of infected people by age (source: https://www.thelancet.com/action/showPdf?pii=S1473-3099%2820%2930243-7)</li>
</ul>
</li>
<p>Using these assumptions, we calculate the number of infectious people in the population by finding the number of people who tested positive within the infectious period, multiplying by the undetected case figure, and subtracting the number of people who are likely to have been hospitalized (based on the age demographics of a county).</p>
<p>Note 1: Because there are so many assumptions baked into this metric, it is certainly not the exact probability that a person on the street is infected. If we assume, however, that these assumptions are fairly stable across counties, we can compare the numbers to get an idea of relative risk between locations.</p>
<p>Note 2: This probability should be considered like a geographically informed prior. There are many other things that need to be accounted for when assigning a probability that an individual is infected. For example, if you go to a bar, the probability that an individual is infectious is probably much higher than the number we report. Bars are filled with people who are (likely regularly) engaging in behavior that may expose them to the virus. Conversely, a person in the waiting room at a doctor's office is probably much less likely to be infectious than our metric. Doctor's offices require temperature checks and screening surveys that lower the probability of an infectious person sitting in the waiting room.</p>
</ul>
<h2>Methodology and Technology</h2>
The map was created with the goal of visualizing the spatial and temporal distributions of various COVID-19 statistics. While there are many similar projects, this one is focused on allowing for easy traversal of time and space. To that end, we have a pseudo-animation feature that lets the user "play out" the pandemic over the country with any metric they choose. At the county level, we give the user the ability to click to see a timeseries visualization for the selected metric. In combination, we aim to give users multiple approaches to visually interrogate the current and past states of the COVID-19 pandemic across a number of metrics.
See the <a href = 'https://github.com/iankloo/bigmap'>repository for the map</a> for the full code base. More documentation is forthcoming there.
<h4>Data</h4>
<p>The data used to generate the map is generated by an R script that is run daily. We are constantly updating this file and it is not stable enough to release publicly at this stage. Eventually, we will add this munge file to the repository.</p>
<p>The case counts and deaths are sourced from <a href = 'https://usafacts.org'>USA Facts</a>. This is the best county-level data set we have found, and it is consistently updated daily. The remainder of the fields are calculated using team's internally developed methodologies.</p>
<h4>Mapping</h4>
<p>This map is a fairly vanilla Leaflet implementation with Javascript (and jQuery) used to implement additional functionality. I stayed away from Leaflet plugins for the most part because they are generally pretty rigid in their implementation and I am particular. The layers on the map are sourced by a geojson created from US Census county boundary shape files.</p>
<h4>Time Slider</h4>
<p>The timeline controls were manually created and added as Leaflet control layers. Adding custom control layers allows for arbitrary HTML elements to be included "on top" of the map. We used jQuery to listen for changes to the time slider which then updates the map using the data for that specific date. The "play" button starts iterating the time slider by one tick on a set time interval (starting either at the current location of the time slider or restarting at the beginning if the slider is in the last position).</p>
<h4>Timeseries Visualization</h4>
<p>Clicking on a county produces a timeseries using <a href = 'https://echarts.apache.org'>Apache's Echarts</a> Javascript implementation. While a user could find the same information by adjusting the time slider, seeing the data in one timeseries visualization supports questions like, "how bad was the COVID-19 pandemic in county X?"</p>
<h4>Colors</h4>
<p>Colors are one of the most controversial topics when it comes to any visualization. We chose to go with a yellow-to-red scale, using grey for NA values. The intent is to get close to an intensity scale while maintaining readability for people with and without color blindness.</p>
<p>Color thresholds are a tricky and are being constantly reevaluated. If possible, we try to make the thresholds meaningful. For example, an R(t) below 0 represents a "good" situation in that case count should continue to decrease so we assign the first threshold at 1 for the R(t) scales.</p>
<h2>About the Authors</h2>
<h4>Ian Kloo</h4>
<p>Ian is a data scientist and is the lead developer on the BigMap project.</p>
<h4>Nick Clark</h4>
<p>Nick is a statistician and creator of the R(t) statistic used on the BigMap project.</p>
<h2>Problems, Concerns, or Feedback?</h2>
<p>Please <a href = 'https://github.com/iankloo/bigmap/issues'>submit an issue</a> on the project repository and we'll do our best to address it/get back to you.</p>
</div>
</div>
</body>
<script>
function openNav() {
if(document.getElementById("Btn2").style.marginRight == "50%"){
document.getElementById("mySidebar").style.width = "0";
document.getElementById("Btn2").style.marginRight = "0";
} else{
document.getElementById("mySidebar").style.width = "50%";
document.getElementById("Btn2").style.marginRight = "50%";
}
}
function closeNav() {
document.getElementById("mySidebar").style.width = "0";
//document.getElementById("main").style.marginRight= "0";
document.getElementById("Btn2").style.marginRight = "0";
}
//--------colors for each layer--------//
function getColor_cases(d) {
return d >= 10000 ? '#BD0026' :
d >= 1000 ? '#F03B20' :
d >= 100 ? '#FD8D3C' :
d >= 10 ? '#FECC5C' :
d >= 0 ? '#FFFFB2' :
'#808080';
}
function getColor_per_delta(d) {
return d >= 20 ? '#800026' :
d >= 10 ? '#BD0026' :
d >= 5 ? '#E31A1C' :
d >= 2 ? '#FC4E2A' :
d >= 1 ? '#FD8D3C' :
d >= .5 ? '#FEB24C' :
d >= 0 ? '#FED976' :
'#808080';
}
function getColor_rt(d) {
return d >= 4 ? '#BD0026' :
d >= 3 ? '#F03B20' :
d >= 2 ? '#FD8D3C' :
d >= 1 ? '#FECC5C' :
d >= 0 ? '#FFFFB2' :
'#808080';
}
function getColor_rt_three(d) {
return d >= 4 ? '#BD0026' :
d >= 3 ? '#F03B20' :
d >= 2 ? '#FD8D3C' :
d >= 1 ? '#FECC5C' :
d >= 0 ? '#FFFFB2' :
'#808080';
}
function getColor_rt_seven(d) {
return d >= 4 ? '#BD0026' :
d >= 3 ? '#F03B20' :
d >= 2 ? '#FD8D3C' :
d >= 1 ? '#FECC5C' :
d >= 0 ? '#FFFFB2' :
'#808080';
}
function getColor_death(d) {
return d > 1000 ? '#BD0026' :
d > 100 ? '#F03B20' :
d > 10 ? '#FD8D3C' :
d > 0 ? '#FFFFB2' :
'#808080';
}
function getColor_doubling(d) {
if(d == null){
return('#808080')
} else if(d < 2){
return('#BD0026')
} else if(d < 5){
return('#F03B20')
} else if(d < 10){
return('#FD8D3C')
} else if(d < 20){
return('#FECC5C')
} else {
return('#FFFFB2')
}
}
function getColor_seven_day_percap(d) {
return d >= 2000 ? '#800026' :
d >= 1500 ? '#B10026' :
d >= 1000 ? '#D41121' :
d >= 500 ? '#FD5D2D' :
d >= 250 ? '#FEAB49' :
d >= 100 ? '#FFE187' :
d >= 0 ? '#FFFFCC' :
'#808080';
}
// function getColor_infectprob(d) {
// return d > 5 ? '#BD0026' :
// d > 2 ? '#F03B20' :
// d > 1 ? '#FD8D3C' :
// d > .5 ? '#FECC5C' :
// d > 0 ? '#FFFFB2' :
// '#808080';
// }
function getColor_infectprob(d) {
return d >= 10 ? '#800026' :
d >= 9 ? '#B10026' :
d >= 8 ? '#D41121' :
d >= 7 ? '#ED3321' :
d >= 6 ? '#FD5D2D' :
d >= 5 ? '#FD8D3C' :
d >= 4 ? '#FEAB49' :
d >= 3 ? '#FFC965' :
d >= 2 ? '#FFE187' :
d >= 1 ? '#FFF1A9' :
d >= 0 ? '#FFFFCC' :
'#808080';
}
//--------highlight controls for each layer--------//
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
weight: 2,
color: '#666',
dashArray: '',
fillOpacity: 0.7
});
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
layer.bringToFront();
}
}
function buildPercapLayer(my_data_var){
function resetHighlight_percap(e) {
percap_layer.resetStyle(e.target);
}
function onEachFeature_percap(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight_percap
});
layer.bindTooltip('<b>'+feature.properties.NAME + '</b><br>7-Day Cases Per 100k: ' + feature.properties[my_data_var])
}
function style_percap(feature){
return{
fillColor: getColor_seven_day_percap(feature.properties[my_data_var]),
weight: .2,
opacity: 1,
color: 'grey',
fillOpacity: 0.7
}
}
percap_layer = L.geoJSON(counties, {
style: style_percap,
onEachFeature: onEachFeature_percap
}).addTo(mymap);
percap_layer.on('click', function(e){
if(typeof testlayer !== "undefined"){
mymap.removeControl(testlayer)
}
L.Control.Plot = L.Control.extend({
onAdd: function(map) {
var container = L.DomUtil.create('div', 'search-container');
container.innerHTML = '<div class = "info"> <button id = "x">X</button><div id="main" style="width:450px; height:275px;"></div> </div>';
//L.DomEvent.disableClickPropagation(container);
return container;
},
onRemove: function(map) {
// Nothing to do here
}
})
L.control.plot = function(opts){
return new L.Control.Plot(opts)
}
$.ajax({
url:"chart_data/"+e.layer.feature.properties.FIPS+".json",
dataType: "json",
success: function(d){
console.log(d)
var plot_dat = d.map(a => a.seven_day_percap);
var dates = d.map(a => a.date)
testlayer = L.control.plot({position: 'topleft'}).addTo(mymap)
var myChart = echarts.init(document.getElementById('main'));
// specify chart configuration item and data
var option = {
title: {
text: 'Timeseries of 7-Day Cases Per 100k in ' + d[0]['County Name']
},
toolbox: {
bottom: '0px',
feature: {
saveAsImage : {show: true, title: " "}
}
},
tooltip: {trigger:"axis"},
xAxis: {
data: dates
},
yAxis: {},
series: [{
name: 'Cases',
type: 'line',
data: plot_dat
}]
};
// use configuration item and data specified to show chart
myChart.setOption(option);
$("#x").click(function(){
mymap.removeControl(testlayer)
})
}
})
})
}
function buildCaseLayer(my_data_var){
function resetHighlight_cases(e) {
case_layer.resetStyle(e.target);
}
function onEachFeature_cases(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight_cases
});
layer.bindTooltip('<b>'+feature.properties.NAME + '</b><br>Cases: ' + feature.properties[my_data_var])
}
function style_cases(feature){
return{
fillColor: getColor_cases(feature.properties[my_data_var]),
weight: .2,
opacity: 1,
color: 'grey',
fillOpacity: 0.7
}
}
case_layer = L.geoJSON(counties, {
style: style_cases,
onEachFeature: onEachFeature_cases
}).addTo(mymap);
case_layer.on('click', function(e){
if(typeof testlayer !== "undefined"){
mymap.removeControl(testlayer)
}
L.Control.Plot = L.Control.extend({
onAdd: function(map) {
var container = L.DomUtil.create('div', 'search-container');
container.innerHTML = '<div class = "info"> <button id = "x">X</button><div id="main" style="width:450px; height:275px;"></div> </div>';
//L.DomEvent.disableClickPropagation(container);
return container;
},
onRemove: function(map) {
// Nothing to do here
}
})
L.control.plot = function(opts){
return new L.Control.Plot(opts)
}
$.ajax({
url:"chart_data/"+e.layer.feature.properties.FIPS+".json",
dataType: "json",
success: function(d){
var plot_dat = d.map(a => a.case_count);
var dates = d.map(a => a.date)
testlayer = L.control.plot({position: 'topleft'}).addTo(mymap)
var myChart = echarts.init(document.getElementById('main'));
// specify chart configuration item and data
var option = {
title: {
text: 'Timeseries of Cases in ' + d[0]['County Name']
},
toolbox: {
bottom: '0px',
feature: {
saveAsImage : {show: true, title: " "}
}
},
tooltip: {trigger:"axis"},
xAxis: {
data: dates
},
yAxis: {},
series: [{
name: 'Cases',
type: 'line',
data: plot_dat
}]
};
// use configuration item and data specified to show chart
myChart.setOption(option);
$("#x").click(function(){
mymap.removeControl(testlayer)
})
}
})
})
}
function buildDeltaLayer(my_data_var){
function resetHighlight_per_inc(e) {
per_inc_layer.resetStyle(e.target);
}
function onEachFeature_per_inc(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight_per_inc
});
layer.bindTooltip('<b>'+feature.properties.NAME + '</b><br>Increase: ' + feature.properties[my_data_var] + "%")
}
function style_per_inc(feature){
return{
fillColor: getColor_per_delta(feature.properties[my_data_var]),
weight: .2,
opacity: 1,
color: 'grey',
fillOpacity: 0.7
}
}
per_inc_layer = L.geoJSON(counties, {
style: style_per_inc,
onEachFeature: onEachFeature_per_inc
}).addTo(mymap);
per_inc_layer.on('click', function(e){
if(typeof testlayer !== "undefined"){
mymap.removeControl(testlayer)
}
L.Control.Plot = L.Control.extend({
onAdd: function(map) {
var container = L.DomUtil.create('div', 'search-container');
container.innerHTML = '<div class = "info"> <button id = "x">X</button><div id="main" style="width:450px; height:275px;"></div> </div>';
//L.DomEvent.disableClickPropagation(container);
return container;
},
onRemove: function(map) {
// Nothing to do here
}
})
L.control.plot = function(opts){
return new L.Control.Plot(opts)
}
$.ajax({
url:"chart_data/"+e.layer.feature.properties.FIPS+".json",
dataType: "json",
success: function(d){
var plot_dat = d.map(a => a.per_delta * 100);
var dates = d.map(a => a.date)
testlayer = L.control.plot({position: 'topleft'}).addTo(mymap)
var myChart = echarts.init(document.getElementById('main'));
// specify chart configuration item and data
var option = {
title: {
text: 'Timeseries of % Increase in ' + d[0]['County Name']
},
toolbox: {
bottom: '0px',
feature: {
saveAsImage : {show: true, title: " "}
}
},
tooltip: {trigger:"axis"},
xAxis: {
data: dates
},
yAxis: {},
series: [{
name: '% Change',
type: 'line',
data: plot_dat
}]
};
// use configuration item and data specified to show chart
myChart.setOption(option);
$("#x").click(function(){
mymap.removeControl(testlayer)
})
}
})
})
}
function buildRtLayer(my_data_var){
function resetHighlight_rt(e) {
rt_layer.resetStyle(e.target);
}
function onEachFeature_rt(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight_rt
});
layer.bindTooltip('<b>'+feature.properties.NAME + '</b><br>R(t): ' + feature.properties[my_data_var])
}
function style_rt(feature){
return{
fillColor: getColor_rt(feature.properties[my_data_var]),
weight: .2,
opacity: 1,
color: 'grey',
fillOpacity: 0.7
}
}
rt_layer = L.geoJSON(counties, {
style: style_rt,
onEachFeature: onEachFeature_rt
}).addTo(mymap);
rt_layer.on('click', function(e){
if(typeof testlayer !== "undefined"){
mymap.removeControl(testlayer)
}
L.Control.Plot = L.Control.extend({
onAdd: function(map) {
var container = L.DomUtil.create('div', 'search-container');
container.innerHTML = '<div class = "info"> <button id = "x">X</button><div id="main" style="width:450px; height:275px;"></div> </div>';
//L.DomEvent.disableClickPropagation(container);
return container;
},
onRemove: function(map) {
// Nothing to do here
}
})
L.control.plot = function(opts){
return new L.Control.Plot(opts)
}
$.ajax({
url:"chart_data/"+e.layer.feature.properties.FIPS+".json",
dataType: "json",
success: function(d){
var plot_dat = d.map(a => a.r_t);
var dates = d.map(a => a.date)
testlayer = L.control.plot({position: 'topleft'}).addTo(mymap)
var myChart = echarts.init(document.getElementById('main'));
// specify chart configuration item and data
var option = {
title: {
text: 'Timeseries of R(t) in ' + d[0]['County Name']
},
toolbox: {
bottom: '0px',
feature: {
saveAsImage : {show: true, title: " "}
}
},
tooltip: {trigger:"axis"},
xAxis: {
data: dates
},
yAxis: {},
series: [{
name: 'R(t)',
type: 'line',
data: plot_dat
}]
};
// use configuration item and data specified to show chart
myChart.setOption(option);
$("#x").click(function(){
mymap.removeControl(testlayer)
})
}
})
})
}
function buildRtThreeLayer(my_data_var){
function resetHighlight_rt_three(e) {
rt_three_layer.resetStyle(e.target);
}
function onEachFeature_rt_three(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight_rt_three
});
layer.bindTooltip('<b>'+feature.properties.NAME + '</b><br>R(t) 3-Day Avg: ' + feature.properties[my_data_var])
}
function style_rt_three(feature){
return{
fillColor: getColor_rt_three(feature.properties[my_data_var]),
weight: .2,
opacity: 1,
color: 'grey',
fillOpacity: 0.7
}
}
rt_three_layer = L.geoJSON(counties, {
style: style_rt_three,
onEachFeature: onEachFeature_rt_three
}).addTo(mymap);