Skip to content

Instantly share code, notes, and snippets.

@seschultz
Last active November 16, 2017 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seschultz/8d2aec940d564a990661632cc2459f38 to your computer and use it in GitHub Desktop.
Save seschultz/8d2aec940d564a990661632cc2459f38 to your computer and use it in GitHub Desktop.
Allegheny County
license: mit

Built with blockbuilder.org

This is a project for CS 573 Data Visualization at Worcester Polytechnic Institute in the Fall of 2017.

The data is about insured people in Allegheny County, PA who have been diagnosed with diabetes and comes from the Allegheny County / City of Pittsburgh / Western PA Regional Data Center published on data.gov.

The page shows a map of Allegheny county as a cholorpleth map, coloring each census tract by the proportion of insured people in that census tract who have been diagnosed with diabetes. The darker the green the higher the number of diagnosed/enrolled.

When hovering over the map, the text shows the number of the census tract currently selected and the proportion of people diagnosed with diabetes.

Clicking on a census tract brings up a bar chart showing the number of people diagnosed in that tract vs number of people enrolled.

forked from shimizu's block: D3.js v4 Mapping Tutorial : GeoJSON

Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
CensusTract TotalEnrolled TotalDiagnosed TotalDiagnosedMedicated WomenEnrolled WomenDiagnosed WomenDiagnosedMedicated MenEnrolled MenDiagnosed MenDiagnosedMedicated
100500 1301 198 113 750 115 58 551 83 55
101100 1170 112 70 653 65 38 517 47 32
101400 1960 202 121 1081 106 61 879 96 60
101600 633 52 33 370 35 23 263 17 10
101700 844 87 58 501 52 38 343 35 20
101800 1589 195 119 894 108 72 695 87 47
010300 614 38 34 276 21 19 338 17 15
110200 2160 160 95 1194 78 47 966 82 48
110600 1576 98 64 869 58 36 707 40 28
111300 1339 109 69 784 61 35 555 48 34
111400 749 55 36 406 41 26 343 14 10
111500 1764 204 124 1056 137 82 708 67 42
120300 894 95 63 544 62 40 350 33 23
120400 441 46 27 254 27 16 187 19 11
120700 417 53 30 242 37 17 175 16 13
120800 396 51 24 236 37 17 160 14 7
130100 1148 109 65 712 68 34 436 41 31
130200 662 86 52 413 59 37 249 27 15
130300 750 88 49 443 57 29 307 31 20
130400 631 70 40 375 43 26 256 27 14
130600 2040 200 120 1238 125 72 802 75 48
140100 1490 86 44 777 37 14 713 49 30
140200 1011 45 22 517 20 12 494 25 10
140300 2072 133 60 1097 72 30 975 61 30
140400 1572 68 40 813 33 19 759 35 21
140500 992 99 56 562 53 28 430 46 28
140600 1959 126 70 1059 71 33 900 55 37
140800 2887 175 92 1491 80 41 1396 95 51
141000 608 43 22 337 24 11 271 19 11
141100 879 84 52 464 42 25 415 42 27
141300 2472 210 77 1312 111 35 1160 99 42
141400 3333 284 139 1746 148 57 1587 136 82
151600 1463 147 84 784 72 40 679 75 44
151700 2820 276 167 1521 158 93 1299 118 74
160800 1218 102 64 636 60 31 582 42 33
160900 1004 120 65 543 75 35 461 45 30
170200 1408 115 58 713 69 32 695 46 26
170600 798 69 43 412 39 23 386 30 20
180300 1313 111 80 765 75 52 548 36 28
180700 1037 121 69 561 69 41 476 52 28
190300 900 82 49 514 44 23 386 38 26
191100 1224 128 64 657 60 25 567 68 39
191400 1223 143 85 660 81 43 563 62 42
191500 994 102 77 529 52 40 465 50 37
191600 2283 227 160 1206 119 85 1077 108 75
191700 1937 195 119 1059 115 69 878 80 50
191800 3111 322 191 1744 180 107 1367 142 84
191900 1207 84 43 658 47 22 549 37 21
192000 1937 216 131 1034 117 70 903 99 61
020100 5438 330 210 2759 172 98 2679 158 112
202200 1512 166 106 846 99 56 666 67 50
202300 2099 259 140 1151 149 66 948 110 74
020300 382 17 7 191 9 2 191 8 5
210700 1108 146 94 644 89 62 464 57 32
220600 789 68 51 394 35 25 395 33 26
240600 1433 141 84 719 69 37 714 72 47
241200 515 69 47 279 36 28 236 33 19
250300 642 45 28 335 27 16 307 18 12
250700 441 31 21 263 17 12 178 14 9
250900 758 67 46 462 36 24 296 31 22
260200 1225 108 73 657 56 35 568 52 38
260700 992 95 61 535 59 34 457 36 27
260900 1191 66 38 694 42 22 497 24 16
261200 648 88 49 344 50 28 304 38 21
261400 1361 154 91 777 106 56 584 48 35
261500 833 88 60 483 53 34 350 35 26
262000 1381 171 95 803 90 47 578 81 48
270100 1406 151 90 805 89 46 601 62 44
270300 1004 91 53 556 53 29 448 38 24
270400 629 66 44 348 43 30 281 23 14
270800 1653 227 111 925 127 57 728 100 54
271500 1853 186 116 1026 99 63 827 87 53
281400 1606 139 88 915 84 42 691 55 46
281500 796 96 60 446 52 32 350 44 28
290100 1311 120 77 708 61 39 603 59 38
290200 2580 267 152 1421 158 80 1159 109 72
290400 2404 226 143 1350 118 78 1054 108 65
300100 2190 248 158 1268 158 98 922 90 60
030500 1132 171 121 706 123 85 426 48 36
310200 2019 259 148 1075 121 61 944 138 87
310300 636 72 39 336 40 21 300 32 18
320400 1145 136 80 614 78 38 531 58 42
320600 1396 126 73 755 59 34 641 67 39
320700 898 109 72 476 56 35 422 53 37
401100 2937 399 204 1636 218 107 1301 181 97
401200 1584 199 104 900 120 63 684 79 41
401300 1760 228 127 958 129 69 802 99 58
040200 639 64 40 368 43 25 271 21 15
402000 1873 257 151 1030 150 91 843 107 60
403500 2444 320 177 1356 185 108 1088 135 69
404000 799 103 71 431 52 36 368 51 35
040500 302 31 15 164 17 3 138 14 12
405000 702 90 42 359 48 22 343 42 20
040600 263 34 14 128 16 3 135 18 11
406000 1451 214 140 727 102 65 724 112 75
407001 3073 327 190 1637 175 104 1436 152 86
407002 3785 377 226 2042 188 106 1743 189 120
408001 3147 309 157 1682 183 85 1465 126 72
408002 3811 264 177 1993 135 88 1818 129 89
040900 837 101 68 450 55 42 387 46 26
409000 6835 378 221 3495 193 93 3340 185 128
410000 677 47 25 347 21 11 330 26 14
411000 3152 185 104 1657 88 47 1495 97 57
412001 4813 291 163 2496 129 68 2317 162 95
412002 3133 216 115 1609 104 47 1524 112 68
413100 3712 294 183 1969 159 83 1743 135 100
413201 2061 192 108 1080 98 46 981 94 62
413202 1564 138 79 858 84 48 706 54 31
413300 2790 312 156 1487 161 66 1303 151 90
413400 2733 258 145 1451 120 61 1282 138 84
413500 3204 386 196 1740 215 103 1464 171 93
414101 3298 256 153 1742 123 83 1556 133 70
414102 4381 391 237 2340 198 115 2041 193 122
414200 3452 278 157 1786 138 75 1666 140 82
415001 2708 202 120 1371 93 59 1337 109 61
415002 1640 136 84 836 68 39 804 68 45
416000 919 131 76 502 70 41 417 61 35
417100 1196 137 83 646 70 39 550 67 44
417200 718 85 57 373 49 33 345 36 24
418000 1063 126 76 595 71 44 468 55 32
419000 1681 222 113 933 130 60 748 92 53
420000 813 91 58 469 55 37 344 36 21
421100 3032 256 133 1608 134 59 1424 122 74
421200 3048 219 129 1596 94 51 1452 125 78
422000 3694 193 119 1867 76 41 1827 117 78
423000 1563 111 65 896 71 38 667 40 27
424000 1959 219 135 1069 128 78 890 91 57
425000 2028 185 118 1107 92 55 921 93 63
426300 3861 396 234 2097 202 105 1764 194 129
426400 2704 295 176 1486 177 105 1218 118 71
426700 1355 162 96 750 76 40 605 86 56
426800 3383 340 204 1777 168 101 1606 172 103
427000 2033 213 123 1114 107 55 919 106 68
427100 3615 348 204 1941 170 101 1674 178 103
427200 3146 312 201 1738 176 119 1408 136 82
428100 773 100 56 409 40 22 364 60 34
428200 1390 157 91 733 72 44 657 85 47
429100 1400 158 87 773 87 48 627 71 39
429201 2409 269 128 1275 148 63 1134 121 65
429202 2893 279 155 1587 138 64 1306 141 91
429300 3339 448 247 1849 250 119 1490 198 128
429400 2367 240 116 1281 124 56 1086 116 60
429500 2383 300 169 1323 170 83 1060 130 86
429600 1885 197 116 1060 116 64 825 81 52
429700 1389 178 107 741 89 52 648 89 55
430100 1147 98 68 636 52 34 511 46 34
430200 2656 284 163 1480 159 93 1176 125 70
431100 1758 170 115 980 85 58 778 85 57
431400 1050 83 54 589 43 25 461 40 29
431500 1495 141 81 813 77 48 682 64 33
432300 1141 168 80 668 111 52 473 57 28
432400 1419 153 98 833 89 51 586 64 47
434000 1102 79 36 583 46 18 519 33 18
435000 1549 149 104 831 73 48 718 76 56
437000 3272 228 139 1707 109 57 1565 119 82
439000 744 63 33 391 32 12 353 31 21
445500 1995 162 87 1117 89 42 878 73 45
446000 1003 76 36 547 36 15 456 40 21
447000 657 46 27 354 25 13 303 21 14
448000 627 70 38 360 42 20 267 28 18
449000 1353 172 110 711 88 54 642 84 56
450700 1566 196 123 861 108 67 705 88 56
450800 1408 190 119 784 108 65 624 82 54
451101 1956 173 100 1060 98 47 896 75 53
451102 2028 211 118 1053 98 55 975 113 63
451104 1919 121 75 1012 59 34 907 62 41
451105 1826 190 122 970 99 62 856 91 60
451300 4079 392 244 2155 194 109 1924 198 135
452000 2317 203 112 1257 107 53 1060 96 59
453003 1008 107 77 517 60 37 491 47 40
453004 3169 277 173 1719 128 79 1450 149 94
455000 888 118 65 466 57 29 422 61 36
456001 1175 78 55 640 36 26 535 42 29
456003 2407 204 120 1282 102 57 1125 102 63
456004 2593 317 142 1464 189 73 1129 128 69
457100 733 99 60 416 60 32 317 39 28
457200 2006 280 157 1120 163 84 886 117 73
458000 4590 508 293 2482 270 132 2108 238 161
459101 1063 107 63 560 57 32 503 50 31
459102 3291 297 167 1754 156 81 1537 141 86
459201 3176 334 186 1678 175 103 1498 159 83
459202 363 29 21 223 17 14 140 12 7
460001 2715 332 184 1493 173 81 1222 159 103
460002 2087 265 144 1121 142 69 966 123 75
461000 504 74 38 272 38 18 232 36 20
462100 1576 167 105 870 93 60 706 74 45
462600 2081 201 133 1163 119 75 918 82 58
463900 1492 171 120 836 93 62 656 78 58
464300 1778 177 113 973 97 63 805 80 50
464400 2063 170 113 1203 103 72 860 67 41
465600 1354 164 83 746 104 50 608 60 33
465800 1929 189 97 1053 103 53 876 86 44
468700 884 98 55 481 49 25 403 49 30
468800 1104 99 60 615 52 24 489 47 36
468900 1964 213 130 1128 131 69 836 82 61
469000 2782 305 153 1513 158 69 1269 147 84
470300 2264 359 151 1293 203 76 971 156 75
470400 1758 206 97 978 102 46 780 104 51
470501 1434 118 72 795 61 36 639 57 36
470502 1767 215 103 977 118 44 790 97 59
470600 1520 187 117 834 92 54 686 95 63
471000 574 59 31 311 32 18 263 27 13
472100 1246 103 58 698 54 25 548 49 33
472200 1128 87 59 585 43 28 543 44 31
472300 965 86 46 536 41 18 429 45 28
472400 1116 101 60 606 42 21 510 59 39
473100 2791 216 101 1500 116 49 1291 100 52
473200 1831 153 78 1042 84 35 789 69 43
473300 3433 341 145 1907 206 75 1526 135 70
473401 2135 134 71 1113 64 31 1022 70 40
473402 1913 168 80 1025 92 39 888 76 41
473500 2173 119 62 1136 56 25 1037 63 37
473601 2266 228 80 1219 135 35 1047 93 45
473602 2689 297 127 1486 171 64 1203 126 63
474101 2435 179 95 1263 86 42 1172 93 53
474102 2228 180 78 1154 97 36 1074 83 42
474201 1556 105 64 813 45 21 743 60 43
474202 2943 317 115 1528 169 47 1415 148 68
474203 2868 209 129 1470 83 45 1398 126 84
475101 2766 381 168 1573 232 93 1193 149 75
475102 1039 106 45 528 53 19 511 53 26
475200 2976 333 189 1573 181 92 1403 152 97
475301 2674 340 174 1437 166 73 1237 174 101
475303 2519 272 141 1333 135 67 1186 137 74
475304 3119 288 151 1673 156 74 1446 132 77
475401 2411 296 147 1303 170 77 1108 126 70
475402 1888 167 82 1013 79 36 875 88 46
476100 2622 284 157 1471 163 88 1151 121 69
476200 1861 208 118 1000 120 65 861 88 53
477100 2167 253 125 1189 134 61 978 119 64
477200 2707 376 174 1516 215 89 1191 161 85
477300 3665 336 184 1912 170 86 1753 166 98
478100 2328 247 131 1266 138 65 1062 109 66
478200 3310 263 147 1801 143 73 1509 120 74
479000 1179 137 74 655 71 37 524 66 37
480101 2949 347 187 1585 200 111 1364 147 76
480102 1836 215 102 999 121 48 837 94 54
480200 2053 230 121 1083 110 51 970 120 70
480300 2204 227 124 1201 119 62 1003 108 62
480400 2957 381 183 1607 197 83 1350 184 100
481000 2078 188 116 1140 116 71 938 72 45
482500 1156 177 89 621 101 44 535 76 45
483800 1734 258 155 1015 157 102 719 101 53
484300 1893 183 91 1026 96 44 867 87 47
484500 3482 427 250 1910 239 132 1572 188 118
484600 1181 148 80 675 89 48 506 59 32
485000 658 68 39 377 41 20 281 27 19
486700 1331 126 78 806 84 50 525 42 28
486800 981 116 79 547 56 32 434 60 47
486900 834 82 53 479 51 34 355 31 19
487000 976 159 87 545 89 42 431 70 45
488100 1817 204 124 949 115 66 868 89 58
488200 2282 247 122 1311 139 60 971 108 62
488300 1468 185 94 814 101 52 654 84 42
488400 2939 348 177 1696 206 96 1243 142 81
488500 1629 184 97 877 85 39 752 99 58
488600 2964 318 182 1681 159 90 1283 159 92
489001 2698 377 183 1493 216 99 1205 161 84
489002 2300 222 103 1204 118 46 1096 104 57
490002 2761 329 174 1498 169 94 1263 160 80
490003 2165 221 113 1121 112 56 1044 109 57
490004 3089 283 152 1634 135 67 1455 148 85
491101 4142 334 171 2207 160 70 1935 174 101
491200 1178 145 79 639 84 43 539 61 36
492700 1092 126 80 640 71 43 452 55 37
492800 1526 184 126 917 119 79 609 65 47
492900 1139 142 88 663 84 52 476 58 36
494000 822 95 60 462 54 34 360 41 26
495000 988 111 68 537 55 34 451 56 34
496101 1870 193 97 1014 117 53 856 76 44
496102 2624 350 193 1403 184 90 1221 166 103
496200 3294 403 206 1785 209 96 1509 194 110
497000 531 63 34 290 29 16 241 34 18
498000 1492 200 115 814 100 52 678 100 63
499300 906 121 61 513 75 32 393 46 29
499400 1587 221 119 893 125 68 694 96 51
500300 2026 224 132 1144 116 65 882 108 67
050100 982 118 76 584 74 46 398 44 30
501000 794 132 80 434 75 43 360 57 37
503002 3541 522 282 1991 321 160 1550 201 122
504100 2669 364 249 1516 217 140 1153 147 109
050600 1021 142 76 590 95 52 431 47 24
507000 1173 137 88 654 75 46 519 62 42
508000 1115 118 73 660 76 45 455 42 28
050900 832 76 58 525 50 40 307 26 18
509400 2921 344 187 1714 204 103 1207 140 84
051000 702 86 62 426 61 46 276 25 16
510000 1171 112 69 654 63 34 517 49 35
051100 74 7 6 47 5 4 27 2 2
512000 1180 170 98 654 87 43 526 83 55
512800 746 85 49 419 48 27 327 37 22
512900 679 81 53 391 53 33 288 28 20
513800 1335 156 90 786 106 56 549 50 34
514000 1171 110 67 694 68 42 477 42 25
515100 1439 149 92 842 87 51 597 62 41
515200 1129 118 77 673 71 47 456 47 30
515300 1040 117 72 644 82 49 396 35 23
515401 1260 102 56 761 66 30 499 36 26
516100 812 60 35 443 28 15 369 32 20
516200 988 68 42 541 40 24 447 28 18
517000 979 140 71 556 75 35 423 65 36
518001 2244 262 127 1293 162 70 951 100 57
519000 1875 221 114 1008 106 48 867 115 66
520001 1821 270 144 1011 138 64 810 132 80
520002 1819 248 132 1033 155 83 786 93 49
521100 2715 321 193 1475 159 91 1240 162 102
521200 2269 268 151 1239 140 66 1030 128 85
521301 2187 307 175 1252 178 100 935 129 75
521302 2287 250 148 1267 151 80 1020 99 68
521401 1540 239 136 862 132 65 678 107 71
521402 2428 249 138 1272 118 69 1156 131 69
521500 2483 325 172 1334 162 74 1149 163 98
522000 1869 202 130 1022 109 68 847 93 62
523100 2231 328 176 1329 198 102 902 130 74
523200 2298 282 165 1324 163 97 974 119 68
523300 2252 279 141 1249 153 70 1003 126 71
523400 2783 383 198 1623 215 109 1160 168 89
523501 2517 334 188 1400 167 87 1117 167 101
523502 807 119 60 468 68 34 339 51 26
523600 2732 416 235 1525 236 124 1207 180 111
523701 2495 319 183 1382 169 87 1113 150 96
523702 3025 405 242 1716 214 120 1309 191 122
523800 2820 391 195 1557 215 99 1263 176 96
524000 1525 154 88 822 78 40 703 76 48
525100 1209 99 45 680 49 20 529 50 25
525200 1224 171 86 735 112 50 489 59 36
525300 1333 174 80 745 104 37 588 70 43
526101 2307 260 141 1242 151 74 1065 109 67
526102 1183 125 57 607 65 31 576 60 26
526201 2263 276 141 1178 152 81 1085 124 60
526202 2771 279 162 1498 133 65 1273 146 97
526301 2421 292 170 1278 153 85 1143 139 85
526302 2658 263 153 1418 133 64 1240 130 89
550900 863 108 70 475 55 33 388 53 37
551200 1777 240 156 1041 143 89 736 97 67
551300 1431 201 113 798 111 47 633 90 66
551900 778 104 70 452 69 48 326 35 22
552000 1626 188 127 938 105 70 688 83 57
552100 915 119 65 541 75 38 374 44 27
552200 643 61 36 350 32 18 293 29 18
552300 1301 152 100 732 87 51 569 65 49
552400 1782 240 158 983 133 86 799 107 72
560400 569 65 32 334 46 23 235 19 9
560500 1127 73 41 635 41 21 492 32 20
560600 476 59 39 276 40 28 200 19 11
561000 635 66 44 370 35 23 265 31 21
561100 450 52 31 263 29 17 187 23 14
561200 591 73 46 339 44 26 252 29 20
561400 2227 318 186 1347 195 116 880 123 70
561500 1400 198 111 822 117 59 578 81 52
561600 1197 106 74 669 66 42 528 40 32
561700 424 38 31 236 23 20 188 15 11
561900 1159 180 110 708 119 74 451 61 36
562000 1020 115 69 543 64 32 477 51 37
562300 1719 241 160 1000 160 108 719 81 52
562400 1520 183 100 848 105 62 672 78 38
562500 1660 147 104 939 85 58 721 62 46
562600 1464 154 98 796 82 49 668 72 49
562700 729 72 37 397 46 24 332 26 13
562800 781 111 66 415 50 32 366 61 34
562900 1115 124 84 633 72 48 482 52 36
563000 1469 171 104 849 94 57 620 77 47
563100 2032 214 128 1066 121 68 966 93 60
563200 1006 130 84 541 67 43 465 63 41
563300 850 49 20 438 22 5 412 27 15
563800 2013 300 109 1089 180 60 924 120 49
563900 2179 265 163 1233 149 95 946 116 68
564000 1757 155 88 945 84 49 812 71 39
564100 595 42 21 311 19 8 284 23 13
564200 1080 156 89 591 86 48 489 70 41
564400 3299 435 258 1826 232 121 1473 203 137
564500 743 64 34 401 41 18 342 23 16
060300 1426 168 74 727 85 42 699 83 32
060500 676 71 34 370 27 14 306 44 20
070300 945 47 17 491 27 10 454 20 7
070500 1117 37 17 580 22 7 537 15 10
070600 1031 57 28 592 35 16 439 22 12
070800 895 34 16 497 15 5 398 19 11
070900 1910 112 49 1021 50 20 889 62 29
080200 838 108 58 469 75 39 369 33 19
080400 605 55 24 310 29 11 295 26 13
080600 1043 65 32 543 36 16 500 29 16
080700 698 35 20 379 17 9 319 18 11
080900 914 84 54 484 54 33 430 30 21
090100 924 75 40 494 42 20 430 33 20
090200 1404 165 93 808 90 50 596 75 43
090300 811 92 59 441 47 26 370 45 33
980000
980100 5 0 0 4 0 0 0 0 0
980700 22 5 5 10 0 0 12 4 4
<!DOCTYPE html>
<meta charset="utf-8">
<style>
text.big-text{
font-size: 28px;
font-weight: 400;
position:absolute;
top: 40px;
left: 20px;
}
text.label{
font-size: 16px;
font-weight: 200;
}
</style>
<html>
<head>
</head>
<body>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3-legend/1.1.0/d3-legend.js"></script>
<script>
var lowColor = '#f9f9f9'
var highColor = '#209222'
var bigText = d3.select("body").append('text')
.classed('big-text', true);
var barSVG = d3.select("body").append('svg')
.attr("width", 200)
.attr("height",200)
.attr("transform", `translate(0, -100)`);
var projection = d3
.geoMercator()
.scale(37000)
.rotate([-0.25, 0.25, 0])
.center([-80.4, 40.5]);
var path = d3.geoPath().projection(projection); 
var map = d3.select("body")
.append("svg")
.attr("width", 960)
.attr("height", 500);
//.attr('transform', `translate(0, 0)`);
function type(d){
d.TotalEnrollment=+d.TotalEnrollment;
d.TotalDiagnosed=+d.TotalDiagnosed;
return d;
}
function barChart(tract){
barSVG.selectAll('rect').remove()
barSVG.selectAll('text').remove()
diagRect=barSVG.append('rect')
.attr('class', 'bar')
.attr('height', +tract.properties.diag/50)
.attr('width', 50)
.attr('fill', 'red')
.attr('transform', `translate(70, 0)`);
diagLabel=barSVG.append('text')
.attr('class','label')
.attr('x',65)
.attr('y', 150)
.text("Diagnosed");
enRect=barSVG.append('rect')
.attr('class', 'bar')
.attr('height', +tract.properties.en/50)
.attr('width', 50)
.attr('fill', 'blue')
.attr('transform', `translate(140, 0)`);
diagLabel=barSVG.append('text')
.attr('class','label')
.attr('x',140)
.attr('y', 150)
.text("Enrolled");
}
function hover(d){
if(d.properties.value==undefined){
valueString='no data'
}
else valueString=d.properties.value
bigText.text('Census Tract ' + d.properties.TRACTCE +', Proportion Diagnosed: ' + valueString);
//barChart(d)
}
d3.csv("diabetes2015_tractNums.csv", type, function(data){
const minVal=0;
const maxVal=0.2;
var ramp = d3.scaleLinear().domain([minVal,maxVal]).range([lowColor,highColor]);
/*var colorLegend = d3.legend.color()
.labelFormat(d3.format(".0f"))
.scale(ramp)
.shapePadding(5)
.shapeWidth(50)
.shapeHeight(20)
.labelOffset(12);
svg.append("g")
.attr("transform", "translate(352, 60)")
.call(colorLegend);*/
d3.json("Allegheny_County_Census_Tracts_2016.geojson", function(json){
// Loop through each census tract value in the .csv file
for (var i = 0; i < data.length; i++) {
// Grab census tract id
var dataTract = data[i].CensusTract;
// Grab proportion diagnosed of those enrolled
var proportionDiag = data[i].TotalDiagnosed/data[i].TotalEnrolled;
// Find the corresponding state inside the GeoJSON
for (var j = 0; j < json.features.length; j++) {
var jsonTract = json.features[j].properties.TRACTCE;
if (dataTract == jsonTract) {
// Copy the data values into the JSON
json.features[j].properties.en = data[i].TotalEnrolled;
json.features[j].properties.diag = data[i].TotalDiagnosed;
json.features[j].properties.value = proportionDiag;
// Stop looking through the JSON
break;
}
}
}
map.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path)
.attr("stroke", "#828282")
.attr("fill", function(d) { return ramp(d.properties.value) })
//.attr("legend", true)
.on("mouseover", function(d){hover(d)})
.on("click", function(d){barChart(d)});
})
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment