-
Notifications
You must be signed in to change notification settings - Fork 0
/
insurance.html
2027 lines (1784 loc) · 78.3 KB
/
insurance.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>
<meta charset="utf-8">
<title>US State Laws Regulating Genetic Discrimination in Insurance</title>
<!--<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Forum&family=Work+Sans:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
<style>
/* Hide scrollbar initially */
.sidebar::-webkit-scrollbar {
display: none;
}
/* Show scrollbar when adjustments are applied */
.sidebar-container.adjusted .sidebar::-webkit-scrollbar {
display: auto;
}
body,
html {
height: 100%;
margin: 0;
font-family: "Forum", serif;
}
label {
font-family: "Work Sans", sans-serif;
font-weight: 300;
}
#mapcontainer {
height: 100vh;
width: calc(100vw - 350px);
/* Adjusted width */
position: absolute;
right: 0;
top: 0;
overflow: hidden;
}
#map {
width: inherit;
height: 100vh; /* Set initial height */
overflow: hidden; /* Prevent overflow if needed */
}
.sidebar-container {
display: flex;
flex-direction: column;
width: 350px;
height: 100%;
position: absolute;
left: 0;
top: 0;
background: white;
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}
.sidebar {
flex: 1;
/* Grow to fill available space */
overflow-y: auto;
/* Enable vertical scrolling */
margin-bottom: 190px;
/* make margin-bottom the same as the height of the legend */
}
.sidebar-header {
padding: 15px 0 15px 15px;
background: #007BFF;
color: white;
text-align: left;
font-size: 18px;
font-weight: bold;
}
.legend,
.filter-legend {
z-index: 1;
}
p {
padding: 0 15px;
font-size: 14px;
font-family: "Work Sans", sans-serif;
font-weight: 300;
}
.layer-control {
margin-top: 20px;
padding-left: 15px;
}
.layer-control input {
margin-right: 5px;
}
.layer-control button {
margin: 10px;
padding: 5px 10px;
background-color: white;
color: black;
box-shadow: 2px 0 3px rgba(0, 0, 0, 0.5);
border: none;
border-radius: 3px;
cursor: pointer;
}
#compareButton {
/* center the button */
display: block;
margin: 0 auto;
padding: 5px 10px;
background-color: white;
color: black;
box-shadow: 2px 0 3px rgba(0, 0, 0, 0.5);
border: none;
border-radius: 3px;
cursor: pointer;
}
.layer-control button:hover,
#compareButton:hover {
background-color: #f0f0f0;
/* very light gray */
}
.checkbox-group {
padding-left: 20px;
margin-bottom: 10px;
}
#tooltip, #hovertooltip {
display: none;
/* Initially hidden */
}
.tooltip, .hovertooltip {
position: absolute;
text-align: left;
padding: 10px;
font: 12px;
font-family: "Forum", serif;
background: lightsteelblue;
border: 1px solid #ccc;
border-radius: 4px;
opacity: 0;
transition: opacity 0.2s ease-in-out;
z-index: 1000;
/* Ensure tooltip is above other elements */
pointer-events: auto;
/* Ensure the tooltip captures mouse events */
}
.tooltip.visible, .hovertooltip.visible {
opacity: 1;
/* Fully visible */
display: block;
/* Use block to show the tooltip */
}
.tooltip.hidden, .hovertooltip.hidden {
opacity: 0;
/* Hide the tooltip */
pointer-events: none;
/* Disable mouse events when hidden */
}
.tooltip .close {
position: absolute;
top: 5px;
right: 5px;
font-size: 16px;
color: black;
/* Set "X" color to black */
background: transparent;
/* Remove background */
border: none;
/* Remove border */
cursor: pointer;
/* Show pointer cursor on hover */
padding: 0;
/* Remove default padding */
}
.tooltip .close:hover {
color: #333;
/* Darker color on hover for better visibility */
}
.highlighted {
stroke: yellow;
stroke-width: 2px;
}
table {
border-collapse: collapse;
width: 100%;
}
th,
td {
border: 1px solid black;
padding: 8px;
text-align: left;
font-family: "Work Sans", sans-serif;
font-weight: 300;
font-size: 13px;
}
.collapsible-header-overview,
.collapsible-header-provisions,
.collapsible-header-comparison,
.collapsible-header-regulation,
.collapsible-header-laws {
cursor: pointer;
}
.arrow-icon {
display: inline-block;
width: 20px;
text-align: center;
}
.collapsible-content-overview,
.collapsible-content-laws {
display: none;
}
.collapsible-content-overview.show,
.collapsible-content-laws.show {
display: block;
}
.collapsible-content-provisions,
.collapsible-content-comparison,
.collapsible-content-regulation {
display: none;
}
/* Modal CSS */
/* Style for the modal background */
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.5);
}
/* Style for the modal content box */
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding-top: 0px;
padding-left: 20px;
padding-bottom: 10px;
padding-right: 20px;
border: 1px solid #888;
width: 80%;
max-width: 500px;
}
/* Style for the close button */
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
/* Style for the table inside the modal */
#stateCompTable {
width: 100%;
border-collapse: collapse;
}
#typeHead,
#firstStateHead,
#secondStateHead,
#Life,
#Disability,
#LTC,
#firstStateLife,
#secondStateLife,
#firstStateDisability,
#secondStateDisability,
#fistStateLTC,
#secondStateLTC {
padding: 8px;
text-align: left;
}
#typeHead,
#firstStateHead,
#secondStateHead {
background-color: #f2f2f2;
}
/* Style for the dropdown container */
.dropdown-container {
display: flex;
justify-content: center;
gap: 10px;
margin-bottom: 20px;
}
#titlebar {
text-align: center;
padding-top: 0px;
border-radius: 5px;
/*box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);*/
}
h1 {
margin: 0;
padding: 10px;
padding-bottom: 13px;
color: black;
font-size: 24px;
font-weight: bold;
}
.centered-text {
max-width: 636px; /* Sets the maximum width */
margin: 0 auto; /* Centers the paragraph itself under the h1 */
text-align: left; /* Left-aligns the text within the paragraph */
}
/* Bottom right text */
.bottom-right {
position: absolute;
bottom: 10px; /* Distance from the bottom */
right: 10px; /* Distance from the right */
font-style: italic; /* To maintain the italic style */
}
</style>
</head>
<body>
<!--A container to hold the sidebar content-->
<div class="sidebar-container">
<div class="sidebar" id="sidebar">
<div class="sidebar-header">US State Laws Regulating Genetic Discrimination in Insurance</div>
<div class="sidebar-content">
<div class="collapsible-overview">
<div class="collapsible-header-overview">
<h4 style="padding: 0 15px;"><span class="arrow-icon">▼</span> <!-- Down-facing arrow icon -->How to Use</h4>
</div>
<div class="collapsible-content-overview show">
<p>To filter the map, select your desired combination of genetic privacy regulations. You will notice the map change based on your combination of radio button and checkbox inputs. The scrollable list of linked regulations will also change according to your selections. Press the reset button to return to the general coverage map.</p>
</div>
</div>
<div class="collapsible-provisions">
<div class="collapsible-header-provisions">
<h4 style="padding: 0 15px;"><span class="arrow-icon">►</span> <!-- Right-facing arrow icon -->Compare Protective Features</h4>
</div>
<div class="collapsible-content-provisions">
<p>There are many different decisions that an insurer makes about an individual. They can make decisions about whether to insure them (underwriting), renew an existing policy, or how much to charge for coverage (premiums). <a href="protective-features-insurance.html" target="_blank">Please click here to compare protective features between a few states.</a></p>
</div>
</div>
<!-- Filter Map by Regulation Type -->
<div class="collapsible-regulation">
<div class="collapsible-header-regulation">
<h4 style="padding: 0 15px;"><span class="arrow-icon">►</span> <!-- Right-facing arrow icon -->Filter Map by Regulation Type</h4>
</div>
<div class="collapsible-content-regulation">
<div class="layer-control">
<div>
<input type="radio" id="lifeLayerToggle" name="layer" value="life">
<label for="lifeLayerToggle">Life Insurance</label>
<div id="lifeLayerOptions" class="checkbox-group" style="display: none; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<input type="checkbox" id="lifeOption2" name="lifeOptions" value="2">
<label for="lifeOption2">Prohibits use of genetic info</label><br>
<input type="checkbox" id="lifeOption4" name="lifeOptions" value="4">
<label for="lifeOption4">Bars use of a specific trait</label><br>
<input type="checkbox" id="lifeOption3" name="lifeOptions" value="3">
<label for="lifeOption3">Allowed if actuarially justified</label><br>
<input type="checkbox" id="lifeOption1" name="lifeOptions" value="1">
<label for="lifeOption1">Requires informed consent</label><br>
<input type="checkbox" id="lifeOption5" name="lifeOptions" value="5">
<label for="lifeOption5">Other</label>
</div>
</div>
<div>
<input type="radio" id="disabilityLayerToggle" name="layer" value="disability">
<label for="disabilityLayerToggle">Disability Insurance</label>
<div id="disabilityLayerOptions" class="checkbox-group" style="display: none; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<input type="checkbox" id="disabilityOption2" name="disabilityOptions" value="2">
<label for="disabilityOption2">Prohibits use of genetic info</label><br>
<input type="checkbox" id="disabilityOption4" name="disabilityOptions" value="4">
<label for="disabilityOption4">Bars use of a specific trait</label><br>
<input type="checkbox" id="disabilityOption3" name="disabilityOptions" value="3">
<label for="disabilityOption3">Allowed if actuarially justified</label><br>
<input type="checkbox" id="disabilityOption1" name="disabilityOptions" value="1">
<label for="disabilityOption1">Requires informed consent</label><br>
<input type="checkbox" id="disabilityOption5" name="disabilityOptions" value="5">
<label for="disabilityOption5">Other</label>
</div>
</div>
<div>
<input type="radio" id="ltcLayerToggle" name="layer" value="ltc">
<label for="ltcLayerToggle">Long-Term Care Insurance</label>
<div id="ltcLayerOptions" class="checkbox-group" style="display: none; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<input type="checkbox" id="ltcOption2" name="ltcOptions" value="2">
<label for="ltcOption2">Prohibits use of genetic info</label><br>
<input type="checkbox" id="ltcOption4" name="ltcOptions" value="4">
<label for="ltcOption4">Bars use of a specific trait</label><br>
<input type="checkbox" id="ltcOption3" name="ltcOptions" value="3">
<label for="ltcOption3">Allowed if actuarially justified</label><br>
<input type="checkbox" id="ltcOption1" name="ltcOptions" value="1">
<label for="ltcOption1">Requires informed consent</label><br>
<input type="checkbox" id="ltcOption5" name="ltcOptions" value="5">
<label for="ltcOption5">Other</label>
</div>
</div>
<!--<button id="filterButton">Filter</button>-->
<button id="resetButton">Reset</button>
</div>
</div>
</div>
<!-- Filter Map by Regulation Type END -->
<!-- STATE LAW COMPARISON START -->
<div class="collapsible-comparison">
<div class="collapsible-header-comparison">
<h4 style="padding: 0 15px;"><span class="arrow-icon">►</span> <!-- Right-facing arrow icon -->Compare State Laws</h4>
</div>
<div class="collapsible-content-comparison">
<p>To compare the legal coverage between two states, select the two states you want to compare from the dropdown menus. Click the "Compare" button and a table will display showing the key legal differences.</p>
<!-- Dropdown menus for selecting states -->
<div class="dropdown-container">
<select id="firstStateDropdown">
<!-- Populate with US states -->
</select>
<select id="secondStateDropdown">
<!-- Populate with US states -->
</select>
</div>
<!-- Trigger/Open The Modal -->
<button id="compareButton">Compare</button>
</div>
</div>
<!-- The Modal -->
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<h2>State Comparison</h2>
<table id="stateCompTable">
<thead>
<tr>
<th id="typeHead">Type</th>
<th id="firstStateHead">None selected</th>
<th id="secondStateHead">None selected</th>
</tr>
</thead>
<tbody>
<tr>
<td id="Life">Life</td>
<td id="firstStateLife"></td>
<td id="secondStateLife"></td>
</tr>
<tr>
<td id="Disability">Disability</td>
<td id="firstStateDisability"></td>
<td id="secondStateDisability"></td>
</tr>
<tr>
<td id="LTC">LTC</td>
<td id="firstStateLTC"></td>
<td id="secondStateLTC"></td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- STATE LAW COMPARISON END -->
<div class="collapsible-laws">
<div class="collapsible-header-laws">
<h4 style="padding: 0 15px;"><span class="arrow-icon">▼</span> <!-- Down-facing arrow icon -->Read the State-by-State Laws</h4>
</div>
<div class="collapsible-content-laws show">
<div id="stateDetails" style="padding: 15px;"></div>
</div>
</div>
</div>
</div>
<div id="legend" style="position: absolute; left: 20px; bottom: 20px; background-color: white; padding: 10px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);">
<h4 style="margin-top: 0; margin-bottom: 0;">Total Categories Covered</h4>
<div>
<!-- Display "patterns/lines-d-02.png" for the case of "Life" coverage-->
<div style="display: flex; align-items: center; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: rgb(173, 216, 230); background-image: url('patterns/lines-d-02.png'); background-size: 20px 20px; background-repeat: repeat; margin-right: 5px;"></span> Life Covered
</div>
<!-- Display "patterns/lines-d-05.png" for the case of "Disability" coverage-->
<div style="display: flex; align-items: center; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: rgb(173, 216, 230); background-image: url('patterns/lines-d-05.png'); background-size: 20px 20px; background-repeat: repeat; margin-right: 5px;"></span> Disability Covered
</div>
<!-- Display "patterns/lines-v-02.png" for the case of "LTC" coverage-->
<div style="display: flex; align-items: center; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: rgb(173, 216, 230); background-image: url('patterns/lines-v-02.png'); background-size: 30px 30px; background-repeat: repeat; margin-right: 5px;"></span> LTC Covered
</div>
<!-- Display "gray" for the case of "No Genetic Privacy Laws"-->
<div style="display: flex; align-items: center; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: rgb(251,247,245); margin-right: 5px;"></span> No Genetic Privacy Laws
</div>
<!--
<div style="display: flex; align-items: center;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: lightblue; margin-right: 5px;"></span> 1 of 3 Categories Covered
</div>
<div style="display: flex; align-items: center;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: blue; margin-right: 5px;"></span> 2 of 3 Categories Covered
</div>
<div style="display: flex; align-items: center;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: darkblue; margin-right: 5px;"></span> Life, Disability, and LTC Covered
</div>
-->
</div>
</div>
<div id="filter-legend" style="position: absolute; left: 20px; bottom: 20px; background-color: white; padding: 10px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);">
<h4 style="margin-top: 0; margin-bottom: 0;">Strength of Coverage</h4>
<div>
<div style="display: flex; align-items: center; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: #03045e; margin-right: 5px;"></span> Prohibits use of genetic info
</div>
<div style="display: flex; align-items: center; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: #0077b6; margin-right: 5px;"></span> Bars use of a specific trait
</div>
<div style="display: flex; align-items: center; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: #00bfd8; margin-right: 5px;"></span> Allowed if actuarially justified
</div>
<div style="display: flex; align-items: center; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: #90e0ef; margin-right: 5px;"></span> Requires informed consent
</div>
<div style="display: flex; align-items: center; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: #caf0f8; margin-right: 5px;"></span> Other
</div>
<div style="display: flex; align-items: center; font-family: Work Sans, sans-serif; font-weight: 300; font-size: 13px;">
<span style="display: inline-block; width: 20px; height: 20px; background-color: rgb(251,247,245); margin-right: 5px;"></span> Absent
</div>
</div>
</div>
</div>
<div id="mapcontainer">
<!--A container in the middle of the page to hold the map title-->
<div id="titlebar">
<h1 class="dynamictitle">US State Laws Regulating Genetic Discrimination in Insurance</h1>
<p class="centered-text">The United States Genetic Information Nondiscrimination Act (GINA) prevents health insurers and employers from engaging in genetic discrimination. However, the federal law does not cover life, long-term care, and disability insurers. These insurances are regulated at the state level. There is a range of different types of laws that states have adopted in this area. This map charts the different categories of laws in place across the states.</p>
</div>
<div id="map">
</div>
<p class="bottom-right"><i>Data current as of October 2024</i></p>
</div>
<div class="tooltip" id="tooltip"></div>
<div class="hovertooltip" id="hovertooltip"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js" integrity="sha512-vc58qvvBdrDR4etbxMdlTt4GBQk1qjvyORR2nrsPsFPyrs+/u5c3+1Ct6upOgdZoIl7eq6k3a1UPDSNAQi/32A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://unpkg.com/[email protected]/dist/topojson.js"></script>
<script>
// Adjust the map height on load
window.onload = function() {
const titlebarHeight = document.getElementById('titlebar').offsetHeight;
document.getElementById('map').style.height = `calc(100vh - ${titlebarHeight}px)`;
};
// Adjust the map height on window resize
window.onresize = function() {
const titlebarHeight = document.getElementById('titlebar').offsetHeight;
document.getElementById('map').style.height = `calc(100vh - ${titlebarHeight}px)`;
};
// Hide the filter-legend by default
document.getElementById('filter-legend').style.display = 'none';
// Hide all checkbox groups by default
document.querySelectorAll('.checkbox-group').forEach(group => {
group.style.display = 'none';
});
// Show the corresponding checkbox group when a radio button is clicked
document.querySelectorAll('input[name="layer"]').forEach(radio => {
radio.addEventListener('change', () => {
document.querySelectorAll('.checkbox-group').forEach(group => {
group.style.display = 'none';
});
const selectedLayer = radio.value;
const checkboxGroup = document.getElementById(selectedLayer + 'LayerOptions');
if (checkboxGroup) {
checkboxGroup.style.display = 'block';
}
});
});
// Ensure radio buttons are unchecked on page reload
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('lifeLayerToggle').checked = false;
document.getElementById('disabilityLayerToggle').checked = false;
document.getElementById('ltcLayerToggle').checked = false;
});
// Ensure that all checkbox inputs are unchecked on page reload
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('input[type="checkbox"]').forEach(checkbox => {
checkbox.checked = false;
});
});
// Event listener for the "Reset" button
document.getElementById('resetButton').addEventListener('click', function() {
// Reload the page
location.reload();
});
// Whenever a radio button is clicked, uncheck all checkboxes
document.querySelectorAll('input[name="layer"]').forEach(radio => {
radio.addEventListener('change', () => {
document.querySelectorAll('input[type="checkbox"]').forEach(checkbox => {
checkbox.checked = false;
});
});
});
// Get the height of the titlebar div
const titlebarHeight = document.getElementById('titlebar').offsetHeight;
// Define the width and height for the SVG
const width = window.innerWidth * 0.75;
const height = window.innerHeight;
// Create the SVG
const svg = d3.select("#map")
.append("svg")
.attr("width", "100%")
.attr("height", "100%")
.attr("viewBox", `0 0 ${width} ${height}`); // Optional: Use viewBox to control scaling
// Define the projection
const projection = d3.geoAlbersUsa()
.translate([width / 2, (height / 2)])
.scale(1000)
// Define the path
const path = d3.geoPath(projection);
// Create a tooltip
const tooltip = d3.select("#tooltip");
// Create a hovertooltip
const hovertooltip = d3.select("#hovertooltip");
// Undefined variable to store the selected filter
let selectedFilter;
let selectedRowKey;
let selectedTitle;
// Load the data
Promise.all([
d3.csv("data/genetic-privacy.csv"),
d3.json("data/states-10m.json")
]).then(makeMap).catch(error => console.error('Error loading data:', error));
// Define an empty object to store the state groups
let stateGroups = {};
// Define the function to make the map
function makeMap([dnaPrivacy, states]) {
// Store the data in a global variable
stateGroups = {
coverageGroup: svg.append("g").attr("id", "coverageLayer"),
filterGroup: svg.append("g").attr("id", "filterLayer"),
};
// Define the pattern and add it to the SVG
svg.append("defs")
.append("pattern")
.attr("id", "crosshatch-pattern-right")
.attr("patternUnits", "userSpaceOnUse")
.attr("width", 15)
.attr("height", 15)
.append("image")
.attr("href", "patterns/lines-d-02.png") // Make sure the path is correct
.attr("x", 0)
.attr("y", 0)
.attr("width", 15)
.attr("height", 15);
// Define the pattern and add it to the SVG
svg.append("defs")
.append("pattern")
.attr("id", "crosshatch-pattern-left")
.attr("patternUnits", "userSpaceOnUse")
.attr("width", 15)
.attr("height", 15)
.append("image")
.attr("href", "patterns/lines-d-05.png") // Make sure the path is correct
.attr("x", 0)
.attr("y", 0)
.attr("width", 15)
.attr("height", 15);
// Define the pattern and add it to the SVG
svg.append("defs")
.append("pattern")
.attr("id", "crosshatch-pattern-vertical")
.attr("patternUnits", "userSpaceOnUse")
.attr("width", 15)
.attr("height", 15)
.append("image")
.attr("href", "patterns/lines-v-02.png") // Make sure the path is correct
.attr("x", 0)
.attr("y", 0)
.attr("width", 15)
.attr("height", 15);
// Define the pattern and add it to the SVG
svg.append("defs")
.append("pattern")
.attr("id", "crosshatch-pattern-cross")
.attr("patternUnits", "userSpaceOnUse")
.attr("width", 15)
.attr("height", 15)
.append("image")
.attr("href", "patterns/lines-d-25.png") // Make sure the path is correct
.attr("x", 0)
.attr("y", 0)
.attr("width", 15)
.attr("height", 15);
// Define the pattern and add it to the SVG
svg.append("defs")
.append("pattern")
.attr("id", "crosshatch-pattern-right-vert")
.attr("patternUnits", "userSpaceOnUse")
.attr("width", 15)
.attr("height", 15)
.append("image")
.attr("href", "patterns/lines-dv-22.png") // Make sure the path is correct
.attr("x", 0)
.attr("y", 0)
.attr("width", 15)
.attr("height", 15);
// Define the pattern and add it to the SVG
svg.append("defs")
.append("pattern")
.attr("id", "crosshatch-pattern-left-vert")
.attr("patternUnits", "userSpaceOnUse")
.attr("width", 15)
.attr("height", 15)
.append("image")
.attr("href", "patterns/lines-dv-25.png") // Make sure the path is correct
.attr("x", 0)
.attr("y", 0)
.attr("width", 15)
.attr("height", 15);
// Define the pattern and add it to the SVG
svg.append("defs")
.append("pattern")
.attr("id", "crosshatch-pattern-all")
.attr("patternUnits", "userSpaceOnUse")
.attr("width", 15)
.attr("height", 15)
.append("image")
.attr("href", "patterns/lines-dv-all.png") // Make sure the path is correct
.attr("x", 0)
.attr("y", 0)
.attr("width", 15)
.attr("height", 15);
// Define the zoom behavior
const zoom = d3.zoom().scaleExtent([0, 8]).on("zoom", zoomed);
// Call the zoom behavior on the SVG
svg.call(zoom);
// Define the zoomed function
function zoomed(event) {
svg.selectAll("g").attr("transform", event.transform);
}
// Get the bounds of the map
const bounds = path.bounds(topojson.feature(states, states.objects.states));
// Calculate the initial scale
const initialScale = Math.min(width / (bounds[1][0] - bounds[0][0]), height / (bounds[1][1] - bounds[0][1])) * 0.9;
// Call the zoom behavior on the SVG
svg.call(zoom.transform, d3.zoomIdentity.translate(width / 2, height / 2).scale(initialScale).translate(-width / 2, -height / 2));
// Listen for a click on a radio button
document.querySelectorAll('input[name="layer"]').forEach(radio => {
radio.addEventListener('click', function() {
// Hide the legend
document.getElementById('legend').style.display = 'none';
// Show the filter-legend
document.getElementById('filter-legend').style.display = 'block';
// Get the current filters
const filters = {
life: document.getElementById('lifeLayerToggle').checked,
disability: document.getElementById('disabilityLayerToggle').checked,
ltc: document.getElementById('ltcLayerToggle').checked
};
// Determine which filter is checked
selectedFilter = Object.keys(filters).find(key => filters[key]);
// If selectedFilter is 'ltc', change selectedRowKey to 'LTC'
if (selectedFilter === 'ltc') {
selectedRowKey = 'LTC';
} else {
// Create a capitalized version of the selected filter
selectedRowKey = selectedFilter.charAt(0).toUpperCase() + selectedFilter.slice(1);
}
// If selectedRowKey is 'LTC', change selectedTitle to 'Long-Term Care'
if (selectedRowKey === 'LTC') {
selectedTitle = 'Long-Term Care';
} else {
// Create a capitalized version of the selected filter
selectedTitle = selectedRowKey;
}
// Feed the selectedTitle to the title bar at the top of the page
document.querySelector('.dynamictitle').textContent = `${selectedTitle} Insurance-Related Laws`;
// Clear previous filters for checkboxes
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
checkboxes.forEach(checkbox => {
checkbox.checked = false; // Reset all checkboxes
});
// Clear previous shading before applying new shading
stateGroups.coverageGroup.selectAll("path").style("fill", "rgb(251,247,245)");
// Iterate through every path (state) and apply a color based on the selectedRowKey value
stateGroups.coverageGroup.selectAll("path")
.style("fill", d => {
// Check if any row in dnaPrivacy matches the state's name and has a truthy selectedRowKey value
const stateName = d.properties.name;
const isStateShadedBlue = dnaPrivacy.some(row => row.State === stateName && row[selectedRowKey]);
// Return the color based on whether any row meets the criteria
return isStateShadedBlue ? "rgb(173,216,230)" : "rgb(251,247,245)";
});
// Add click event listeners to checkboxes again, if they were reset
checkboxes.forEach(checkbox => {
checkbox.addEventListener('click', function() {
// Get the layer options filters using selectedFilter
const subfilters = Object.fromEntries(
Array.from(document.querySelectorAll('input[name="' + selectedFilter + 'Options"]'))
.map(option => [option.value, option.checked])
);
// Apply the filters
applyFilters(states, dnaPrivacy, filters, subfilters);
});
});
// Apply initial filters when a radio button is clicked (after checkbox resets)
applyFilters(states, dnaPrivacy, filters, {});
});
});
stateGroups.coverageGroup.style("visibility", "visible");
stateGroups.filterGroup.style("visibility", "hidden");
const groupedData = groupAndCountEntriesForStates(dnaPrivacy);
// Draw initial map
drawCoverageLayer(stateGroups.coverageGroup, states, groupedData);
// Populate the sidebar with all state details
populateStateDetails(groupedData);
// STATE LAW COMPARISON START
// List of US states
const compStates = [
"None selected", "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut",
"Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa",
"Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan",
"Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire",
"New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio",
"Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota",
"Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia",
"Wisconsin", "Wyoming"
];
// Populate the dropdown menus
const firstStateDropdown = document.getElementById('firstStateDropdown');
const secondStateDropdown = document.getElementById('secondStateDropdown');
compStates.forEach(state => {
const option1 = document.createElement('option');
option1.value = state;
option1.textContent = state;
firstStateDropdown.appendChild(option1);
const option2 = document.createElement('option');
option2.value = state;
option2.textContent = state;
secondStateDropdown.appendChild(option2);
});
// Get the modal
const modal = document.getElementById("myModal");
// Get the button that opens the modal
const btn = document.getElementById("compareButton");
// Get the <span> element that closes the modal
const span = document.getElementsByClassName("close")[0];
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
// Update the table headers when a state is selected
firstStateDropdown.onchange = function() {
document.getElementById('firstStateHead').textContent = firstStateDropdown.value;
}
secondStateDropdown.onchange = function() {
// Prevent the user from selecting the same state in both dropdowns
if (firstStateDropdown.value === secondStateDropdown.value) {
alert('Please select two different states to compare.');
secondStateDropdown.value = 'None selected';
}
document.getElementById('secondStateHead').textContent = secondStateDropdown.value;
}
// create an empty array to store the firstStateLife values
const firstStateLife = [];
// create an empty array to store the secondStateLife values
const secondStateLife = [];
// create an empty array to store the firstStateDisability values
const firstStateDisability = [];
// create an empty array to store the secondStateDisability values
const secondStateDisability = [];
// create an empty array to store the firstStateLTC values
const firstStateLTC = [];
// create an empty array to store the secondStateLTC values
const secondStateLTC = [];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
// clear the arrays
firstStateLife.length = 0;
secondStateLife.length = 0;
firstStateDisability.length = 0;
secondStateDisability.length = 0;
firstStateLTC.length = 0;
secondStateLTC.length = 0;
// run needed functions here
// Iterate through each key in the first object of groupAndCountEntriesForComparison(dnaPrivacy, firstStateDropdown.value, secondStateDropdown.value)
const firstState = groupAndCountEntriesForComparison(dnaPrivacy, firstStateDropdown.value, secondStateDropdown.value)[0][firstStateDropdown.value];
const secondState = groupAndCountEntriesForComparison(dnaPrivacy, firstStateDropdown.value, secondStateDropdown.value)[1][secondStateDropdown.value];