Age of drivers by state
Last active
August 22, 2016 02:24
-
-
Save 1wheel/f3ea4168386371ba5475 to your computer and use it in GitHub Desktop.
driver-age
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state | 19 | 20-24 | 25-29 | 30-34 | 35-39 | 40-44 | 45-49 | 50-54 | 55-59 | 60-64 | 65-69 | 70-74 | 75-79 | 80-84 | 85+ | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Alabama | 213,502 | 334,979 | 332,552 | 314,898 | 294,818 | 318,550 | 317,823 | 344,475 | 333,114 | 292,978 | 248,061 | 186,023 | 137,376 | 97,881 | 92,373 | |
Alaska | 20,896 | 48,046 | 58,503 | 56,199 | 46,478 | 45,642 | 45,094 | 51,519 | 50,863 | 41,851 | 28,273 | 16,970 | 7,813 | 6,645 | 4,081 | |
Arizona | 168,079 | 373,144 | 421,535 | 453,215 | 437,431 | 456,264 | 435,507 | 454,261 | 423,855 | 379,624 | 283,272 | 206,248 | 140,139 | 92,910 | 65,966 | |
Arkansas | 95,075 | 179,264 | 176,529 | 176,360 | 165,042 | 173,674 | 173,983 | 191,688 | 182,832 | 164,979 | 144,055 | 108,842 | 76,562 | 50,030 | 38,286 | |
California | 1,203,098 | 2,319,579 | 2,271,035 | 2,204,134 | 2,079,386 | 2,270,165 | 2,338,038 | 2,372,133 | 2,136,031 | 1,756,205 | 1,307,964 | 851,267 | 577,901 | 402,247 | 301,053 | |
Colorado | 149,161 | 296,848 | 354,097 | 366,960 | 334,585 | 347,743 | 337,411 | 375,399 | 361,252 | 311,449 | 238,474 | 135,899 | 92,626 | 67,696 | 67,888 | |
Connecticut | 91,152 | 201,778 | 208,049 | 196,325 | 189,249 | 222,907 | 253,209 | 266,849 | 246,039 | 197,862 | 159,446 | 111,150 | 76,818 | 59,305 | 53,952 | |
Delaware | 35,319 | 60,028 | 63,145 | 61,725 | 54,489 | 60,039 | 63,668 | 67,022 | 62,833 | 55,046 | 48,737 | 36,118 | 24,326 | 17,327 | 13,835 | |
Dist. of Col. | 632 | 14,012 | 54,330 | 70,452 | 53,171 | 40,773 | 32,532 | 30,389 | 27,402 | 25,172 | 21,165 | 14,331 | 9,111 | 6,059 | 6,024 | |
Florida | 442,182 | 1,017,632 | 1,082,561 | 1,060,373 | 1,025,285 | 1,160,437 | 1,228,255 | 1,326,944 | 1,235,132 | 1,108,270 | 1,006,360 | 775,140 | 544,147 | 369,890 | 287,833 | |
Georgia | 275,429 | 560,612 | 566,009 | 583,723 | 574,801 | 652,880 | 645,955 | 645,716 | 582,467 | 496,969 | 393,813 | 266,479 | 173,925 | 110,448 | 77,790 | |
Hawaii | 25,803 | 72,742 | 83,927 | 82,939 | 77,568 | 83,540 | 86,507 | 88,525 | 87,212 | 78,691 | 57,944 | 37,014 | 24,281 | 17,324 | 11,016 | |
Idaho | 62,398 | 98,022 | 95,118 | 98,800 | 92,055 | 90,316 | 88,822 | 99,723 | 98,788 | 89,986 | 73,968 | 52,801 | 34,727 | 21,337 | 14,624 | |
Illinois | 419,518 | 699,925 | 712,693 | 717,946 | 675,639 | 714,210 | 737,164 | 802,186 | 766,907 | 649,056 | 504,826 | 363,201 | 243,149 | 123,650 | 131,512 | |
Indiana | 190,581 | 393,559 | 387,264 | 386,628 | 365,039 | 393,586 | 401,749 | 436,704 | 417,748 | 354,869 | 275,084 | 199,222 | 137,898 | 92,332 | 68,140 | |
Iowa | 129,368 | 184,468 | 179,263 | 175,903 | 158,595 | 165,584 | 176,424 | 203,906 | 198,977 | 175,148 | 133,403 | 99,005 | 72,561 | 51,797 | 39,263 | |
Kansas | 145,503 | 175,074 | 180,953 | 172,944 | 152,819 | 154,127 | 156,633 | 185,149 | 181,908 | 156,800 | 121,674 | 86,450 | 62,696 | 45,909 | 39,120 | |
Kentucky | 79,799 | 241,831 | 247,118 | 260,263 | 251,309 | 272,912 | 279,516 | 299,928 | 287,715 | 250,724 | 199,654 | 143,281 | 97,010 | 63,174 | 45,049 | |
Louisiana | 138,616 | 265,376 | 295,978 | 307,050 | 270,496 | 276,314 | 285,256 | 307,446 | 295,902 | 252,535 | 196,912 | 141,745 | 100,541 | 72,340 | 71,636 | |
Maine | 36,875 | 73,586 | 77,478 | 74,000 | 70,306 | 81,849 | 90,480 | 104,233 | 103,427 | 92,923 | 76,107 | 46,096 | 33,258 | 25,414 | 25,353 | |
Maryland | 125,544 | 318,166 | 378,731 | 390,089 | 355,592 | 386,022 | 410,572 | 424,018 | 380,668 | 313,730 | 244,048 | 165,330 | 109,072 | 76,097 | 62,426 | |
Massachusetts | 165,129 | 384,400 | 433,256 | 416,404 | 379,802 | 414,973 | 452,674 | 478,042 | 441,943 | 371,989 | 299,830 | 203,203 | 137,383 | 100,202 | 86,356 | |
Michigan | 314,156 | 605,547 | 560,658 | 539,929 | 518,047 | 583,733 | 615,885 | 683,036 | 675,823 | 582,548 | 459,109 | 332,942 | 228,303 | 158,537 | 128,334 | |
Minnesota | 162,640 | 237,145 | 247,181 | 267,830 | 250,718 | 267,844 | 292,172 | 345,521 | 329,624 | 284,233 | 218,360 | 159,062 | 114,009 | 82,010 | 72,376 | |
Mississippi | 108,116 | 168,989 | 160,127 | 161,547 | 155,065 | 166,446 | 167,242 | 185,719 | 180,798 | 158,778 | 129,708 | 94,076 | 66,235 | 41,708 | 24,353 | |
Missouri | 207,788 | 362,954 | 381,414 | 376,654 | 334,450 | 354,684 | 365,418 | 416,173 | 389,285 | 334,299 | 268,139 | 199,656 | 135,589 | 90,986 | 62,949 | |
Montana | 36,955 | 58,724 | 66,346 | 63,712 | 56,808 | 56,643 | 58,964 | 72,876 | 76,443 | 70,890 | 55,220 | 39,870 | 25,826 | 17,044 | 10,395 | |
Nebraska | 73,059 | 120,981 | 129,362 | 125,693 | 108,951 | 107,298 | 108,415 | 126,409 | 120,870 | 106,418 | 80,601 | 57,603 | 43,088 | 34,081 | 31,700 | |
Nevada | 57,563 | 134,302 | 149,478 | 159,196 | 153,207 | 166,850 | 163,436 | 165,729 | 155,987 | 139,933 | 121,717 | 85,254 | 53,481 | 31,124 | 18,838 | |
New Hampshire | 48,687 | 88,572 | 85,015 | 78,727 | 74,643 | 91,452 | 102,188 | 114,303 | 105,649 | 87,224 | 69,284 | 46,692 | 30,961 | 21,556 | 16,480 | |
New Jersey | 193,245 | 510,749 | 493,340 | 484,462 | 487,143 | 540,802 | 590,001 | 626,210 | 576,886 | 470,544 | 382,127 | 269,988 | 187,271 | 140,881 | 127,737 | |
New Mexico | 33,152 | 121,152 | 137,084 | 138,815 | 124,855 | 124,439 | 128,341 | 142,402 | 137,603 | 124,308 | 96,826 | 66,332 | 41,141 | 25,571 | 14,479 | |
New York | 334,991 | 834,654 | 938,518 | 942,917 | 922,754 | 1,054,948 | 1,142,252 | 1,150,811 | 1,030,395 | 892,087 | 661,440 | 460,797 | 344,773 | 265,262 | 234,184 | |
North Carolina | 216,046 | 575,510 | 594,464 | 598,932 | 583,320 | 651,783 | 641,677 | 656,242 | 611,302 | 521,598 | 437,445 | 306,376 | 203,570 | 132,523 | 92,114 | |
North Dakota | 28,856 | 48,621 | 52,270 | 46,813 | 38,307 | 37,386 | 39,456 | 47,658 | 47,127 | 39,424 | 28,669 | 20,523 | 16,206 | 12,453 | 10,069 | |
Ohio | 438,900 | 667,319 | 623,431 | 630,230 | 597,190 | 673,221 | 706,442 | 783,402 | 773,398 | 661,483 | 509,698 | 372,491 | 265,498 | 185,419 | 142,299 | |
Oklahoma | 143,911 | 221,441 | 216,045 | 210,186 | 182,217 | 185,585 | 183,927 | 214,661 | 210,923 | 185,464 | 158,032 | 118,116 | 86,363 | 57,465 | 43,971 | |
Oregon | 94,249 | 201,104 | 231,458 | 253,218 | 237,102 | 235,112 | 225,225 | 244,970 | 257,786 | 248,312 | 202,804 | 140,840 | 91,195 | 59,558 | 50,440 | |
Pennsylvania | 303,227 | 697,696 | 719,186 | 703,404 | 654,472 | 745,922 | 810,611 | 889,208 | 871,773 | 744,490 | 588,173 | 429,812 | 313,809 | 237,044 | 187,763 | |
Rhode Island | 23,915 | 61,550 | 63,842 | 61,721 | 56,099 | 62,201 | 70,095 | 76,160 | 73,665 | 61,831 | 49,736 | 34,047 | 22,464 | 16,711 | 15,195 | |
South Carolina | 208,438 | 295,508 | 303,058 | 298,502 | 276,012 | 302,105 | 303,534 | 318,213 | 307,114 | 282,420 | 246,687 | 172,123 | 109,224 | 67,772 | 45,694 | |
South Dakota | 34,231 | 49,726 | 52,064 | 51,605 | 44,944 | 43,305 | 45,607 | 55,828 | 55,816 | 51,476 | 40,461 | 29,863 | 21,235 | 15,126 | 12,356 | |
Tennessee | 233,639 | 370,880 | 372,570 | 375,949 | 363,101 | 407,091 | 412,595 | 434,674 | 416,116 | 368,680 | 307,105 | 220,656 | 149,871 | 98,548 | 73,625 | |
Texas | 650,020 | 1,387,600 | 1,421,705 | 1,435,641 | 1,363,733 | 1,445,246 | 1,406,145 | 1,487,933 | 1,368,796 | 1,139,645 | 888,659 | 608,280 | 411,879 | 265,517 | 166,474 | |
Utah | 110,558 | 171,155 | 178,458 | 184,864 | 167,215 | 139,252 | 121,360 | 129,298 | 123,184 | 103,010 | 81,435 | 59,095 | 41,575 | 28,485 | 22,275 | |
Vermont | 19,653 | 41,010 | 50,726 | 45,153 | 39,413 | 42,805 | 46,440 | 53,067 | 52,581 | 46,695 | 36,641 | 25,276 | 17,086 | 12,857 | 13,654 | |
Virginia | 219,761 | 452,252 | 485,947 | 493,892 | 462,728 | 513,943 | 536,244 | 564,092 | 517,210 | 435,620 | 349,090 | 239,803 | 158,445 | 102,905 | 70,833 | |
Washington | 199,118 | 430,261 | 498,350 | 524,715 | 478,435 | 486,273 | 464,986 | 496,115 | 478,311 | 415,358 | 327,200 | 207,775 | 137,067 | 89,411 | 68,255 | |
West Virginia | 56,316 | 67,303 | 77,672 | 83,623 | 87,421 | 97,496 | 99,008 | 109,933 | 119,066 | 114,896 | 94,579 | 67,580 | 48,307 | 31,461 | 22,475 | |
Wisconsin | 195,729 | 337,425 | 352,865 | 353,441 | 318,826 | 346,576 | 382,953 | 421,667 | 390,336 | 331,727 | 247,393 | 177,281 | 129,383 | 98,298 | 87,527 | |
Wyoming | 21,609 | 35,051 | 38,470 | 37,975 | 32,774 | 31,939 | 31,428 | 39,241 | 41,633 | 36,490 | 27,754 | 19,291 | 13,023 | 8,555 | 6,240 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var colorbrewer = {YlGn: { | |
3: ["#f7fcb9","#addd8e","#31a354"], | |
4: ["#ffffcc","#c2e699","#78c679","#238443"], | |
5: ["#ffffcc","#c2e699","#78c679","#31a354","#006837"], | |
6: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#31a354","#006837"], | |
7: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"], | |
8: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"], | |
9: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"] | |
},YlGnBu: { | |
3: ["#edf8b1","#7fcdbb","#2c7fb8"], | |
4: ["#ffffcc","#a1dab4","#41b6c4","#225ea8"], | |
5: ["#ffffcc","#a1dab4","#41b6c4","#2c7fb8","#253494"], | |
6: ["#ffffcc","#c7e9b4","#7fcdbb","#41b6c4","#2c7fb8","#253494"], | |
7: ["#ffffcc","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#0c2c84"], | |
8: ["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#0c2c84"], | |
9: ["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"] | |
},GnBu: { | |
3: ["#e0f3db","#a8ddb5","#43a2ca"], | |
4: ["#f0f9e8","#bae4bc","#7bccc4","#2b8cbe"], | |
5: ["#f0f9e8","#bae4bc","#7bccc4","#43a2ca","#0868ac"], | |
6: ["#f0f9e8","#ccebc5","#a8ddb5","#7bccc4","#43a2ca","#0868ac"], | |
7: ["#f0f9e8","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#08589e"], | |
8: ["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#08589e"], | |
9: ["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"] | |
},BuGn: { | |
3: ["#e5f5f9","#99d8c9","#2ca25f"], | |
4: ["#edf8fb","#b2e2e2","#66c2a4","#238b45"], | |
5: ["#edf8fb","#b2e2e2","#66c2a4","#2ca25f","#006d2c"], | |
6: ["#edf8fb","#ccece6","#99d8c9","#66c2a4","#2ca25f","#006d2c"], | |
7: ["#edf8fb","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#005824"], | |
8: ["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#005824"], | |
9: ["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"] | |
},PuBuGn: { | |
3: ["#ece2f0","#a6bddb","#1c9099"], | |
4: ["#f6eff7","#bdc9e1","#67a9cf","#02818a"], | |
5: ["#f6eff7","#bdc9e1","#67a9cf","#1c9099","#016c59"], | |
6: ["#f6eff7","#d0d1e6","#a6bddb","#67a9cf","#1c9099","#016c59"], | |
7: ["#f6eff7","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016450"], | |
8: ["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016450"], | |
9: ["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"] | |
},PuBu: { | |
3: ["#ece7f2","#a6bddb","#2b8cbe"], | |
4: ["#f1eef6","#bdc9e1","#74a9cf","#0570b0"], | |
5: ["#f1eef6","#bdc9e1","#74a9cf","#2b8cbe","#045a8d"], | |
6: ["#f1eef6","#d0d1e6","#a6bddb","#74a9cf","#2b8cbe","#045a8d"], | |
7: ["#f1eef6","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#034e7b"], | |
8: ["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#034e7b"], | |
9: ["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"] | |
},BuPu: { | |
3: ["#e0ecf4","#9ebcda","#8856a7"], | |
4: ["#edf8fb","#b3cde3","#8c96c6","#88419d"], | |
5: ["#edf8fb","#b3cde3","#8c96c6","#8856a7","#810f7c"], | |
6: ["#edf8fb","#bfd3e6","#9ebcda","#8c96c6","#8856a7","#810f7c"], | |
7: ["#edf8fb","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#6e016b"], | |
8: ["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#6e016b"], | |
9: ["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"] | |
},RdPu: { | |
3: ["#fde0dd","#fa9fb5","#c51b8a"], | |
4: ["#feebe2","#fbb4b9","#f768a1","#ae017e"], | |
5: ["#feebe2","#fbb4b9","#f768a1","#c51b8a","#7a0177"], | |
6: ["#feebe2","#fcc5c0","#fa9fb5","#f768a1","#c51b8a","#7a0177"], | |
7: ["#feebe2","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177"], | |
8: ["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177"], | |
9: ["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"] | |
},PuRd: { | |
3: ["#e7e1ef","#c994c7","#dd1c77"], | |
4: ["#f1eef6","#d7b5d8","#df65b0","#ce1256"], | |
5: ["#f1eef6","#d7b5d8","#df65b0","#dd1c77","#980043"], | |
6: ["#f1eef6","#d4b9da","#c994c7","#df65b0","#dd1c77","#980043"], | |
7: ["#f1eef6","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#91003f"], | |
8: ["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#91003f"], | |
9: ["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"] | |
},OrRd: { | |
3: ["#fee8c8","#fdbb84","#e34a33"], | |
4: ["#fef0d9","#fdcc8a","#fc8d59","#d7301f"], | |
5: ["#fef0d9","#fdcc8a","#fc8d59","#e34a33","#b30000"], | |
6: ["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#e34a33","#b30000"], | |
7: ["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#990000"], | |
8: ["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#990000"], | |
9: ["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"] | |
},YlOrRd: { | |
3: ["#ffeda0","#feb24c","#f03b20"], | |
4: ["#ffffb2","#fecc5c","#fd8d3c","#e31a1c"], | |
5: ["#ffffb2","#fecc5c","#fd8d3c","#f03b20","#bd0026"], | |
6: ["#ffffb2","#fed976","#feb24c","#fd8d3c","#f03b20","#bd0026"], | |
7: ["#ffffb2","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026"], | |
8: ["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026"], | |
9: ["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"] | |
},YlOrBr: { | |
3: ["#fff7bc","#fec44f","#d95f0e"], | |
4: ["#ffffd4","#fed98e","#fe9929","#cc4c02"], | |
5: ["#ffffd4","#fed98e","#fe9929","#d95f0e","#993404"], | |
6: ["#ffffd4","#fee391","#fec44f","#fe9929","#d95f0e","#993404"], | |
7: ["#ffffd4","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#8c2d04"], | |
8: ["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#8c2d04"], | |
9: ["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"] | |
},Purples: { | |
3: ["#efedf5","#bcbddc","#756bb1"], | |
4: ["#f2f0f7","#cbc9e2","#9e9ac8","#6a51a3"], | |
5: ["#f2f0f7","#cbc9e2","#9e9ac8","#756bb1","#54278f"], | |
6: ["#f2f0f7","#dadaeb","#bcbddc","#9e9ac8","#756bb1","#54278f"], | |
7: ["#f2f0f7","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#4a1486"], | |
8: ["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#4a1486"], | |
9: ["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"] | |
},Blues: { | |
3: ["#deebf7","#9ecae1","#3182bd"], | |
4: ["#eff3ff","#bdd7e7","#6baed6","#2171b5"], | |
5: ["#eff3ff","#bdd7e7","#6baed6","#3182bd","#08519c"], | |
6: ["#eff3ff","#c6dbef","#9ecae1","#6baed6","#3182bd","#08519c"], | |
7: ["#eff3ff","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#084594"], | |
8: ["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#084594"], | |
9: ["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"] | |
},Greens: { | |
3: ["#e5f5e0","#a1d99b","#31a354"], | |
4: ["#edf8e9","#bae4b3","#74c476","#238b45"], | |
5: ["#edf8e9","#bae4b3","#74c476","#31a354","#006d2c"], | |
6: ["#edf8e9","#c7e9c0","#a1d99b","#74c476","#31a354","#006d2c"], | |
7: ["#edf8e9","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#005a32"], | |
8: ["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#005a32"], | |
9: ["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"] | |
},Oranges: { | |
3: ["#fee6ce","#fdae6b","#e6550d"], | |
4: ["#feedde","#fdbe85","#fd8d3c","#d94701"], | |
5: ["#feedde","#fdbe85","#fd8d3c","#e6550d","#a63603"], | |
6: ["#feedde","#fdd0a2","#fdae6b","#fd8d3c","#e6550d","#a63603"], | |
7: ["#feedde","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#8c2d04"], | |
8: ["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#8c2d04"], | |
9: ["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"] | |
},Reds: { | |
3: ["#fee0d2","#fc9272","#de2d26"], | |
4: ["#fee5d9","#fcae91","#fb6a4a","#cb181d"], | |
5: ["#fee5d9","#fcae91","#fb6a4a","#de2d26","#a50f15"], | |
6: ["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#de2d26","#a50f15"], | |
7: ["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#99000d"], | |
8: ["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#99000d"], | |
9: ["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"] | |
},Greys: { | |
3: ["#f0f0f0","#bdbdbd","#636363"], | |
4: ["#f7f7f7","#cccccc","#969696","#525252"], | |
5: ["#f7f7f7","#cccccc","#969696","#636363","#252525"], | |
6: ["#f7f7f7","#d9d9d9","#bdbdbd","#969696","#636363","#252525"], | |
7: ["#f7f7f7","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"], | |
8: ["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"], | |
9: ["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"] | |
},PuOr: { | |
3: ["#f1a340","#f7f7f7","#998ec3"], | |
4: ["#e66101","#fdb863","#b2abd2","#5e3c99"], | |
5: ["#e66101","#fdb863","#f7f7f7","#b2abd2","#5e3c99"], | |
6: ["#b35806","#f1a340","#fee0b6","#d8daeb","#998ec3","#542788"], | |
7: ["#b35806","#f1a340","#fee0b6","#f7f7f7","#d8daeb","#998ec3","#542788"], | |
8: ["#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788"], | |
9: ["#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788"], | |
10: ["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"], | |
11: ["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"] | |
},BrBG: { | |
3: ["#d8b365","#f5f5f5","#5ab4ac"], | |
4: ["#a6611a","#dfc27d","#80cdc1","#018571"], | |
5: ["#a6611a","#dfc27d","#f5f5f5","#80cdc1","#018571"], | |
6: ["#8c510a","#d8b365","#f6e8c3","#c7eae5","#5ab4ac","#01665e"], | |
7: ["#8c510a","#d8b365","#f6e8c3","#f5f5f5","#c7eae5","#5ab4ac","#01665e"], | |
8: ["#8c510a","#bf812d","#dfc27d","#f6e8c3","#c7eae5","#80cdc1","#35978f","#01665e"], | |
9: ["#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e"], | |
10: ["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"], | |
11: ["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"] | |
},PRGn: { | |
3: ["#af8dc3","#f7f7f7","#7fbf7b"], | |
4: ["#7b3294","#c2a5cf","#a6dba0","#008837"], | |
5: ["#7b3294","#c2a5cf","#f7f7f7","#a6dba0","#008837"], | |
6: ["#762a83","#af8dc3","#e7d4e8","#d9f0d3","#7fbf7b","#1b7837"], | |
7: ["#762a83","#af8dc3","#e7d4e8","#f7f7f7","#d9f0d3","#7fbf7b","#1b7837"], | |
8: ["#762a83","#9970ab","#c2a5cf","#e7d4e8","#d9f0d3","#a6dba0","#5aae61","#1b7837"], | |
9: ["#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837"], | |
10: ["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"], | |
11: ["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"] | |
},PiYG: { | |
3: ["#e9a3c9","#f7f7f7","#a1d76a"], | |
4: ["#d01c8b","#f1b6da","#b8e186","#4dac26"], | |
5: ["#d01c8b","#f1b6da","#f7f7f7","#b8e186","#4dac26"], | |
6: ["#c51b7d","#e9a3c9","#fde0ef","#e6f5d0","#a1d76a","#4d9221"], | |
7: ["#c51b7d","#e9a3c9","#fde0ef","#f7f7f7","#e6f5d0","#a1d76a","#4d9221"], | |
8: ["#c51b7d","#de77ae","#f1b6da","#fde0ef","#e6f5d0","#b8e186","#7fbc41","#4d9221"], | |
9: ["#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221"], | |
10: ["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"], | |
11: ["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"] | |
},RdBu: { | |
3: ["#ef8a62","#f7f7f7","#67a9cf"], | |
4: ["#ca0020","#f4a582","#92c5de","#0571b0"], | |
5: ["#ca0020","#f4a582","#f7f7f7","#92c5de","#0571b0"], | |
6: ["#b2182b","#ef8a62","#fddbc7","#d1e5f0","#67a9cf","#2166ac"], | |
7: ["#b2182b","#ef8a62","#fddbc7","#f7f7f7","#d1e5f0","#67a9cf","#2166ac"], | |
8: ["#b2182b","#d6604d","#f4a582","#fddbc7","#d1e5f0","#92c5de","#4393c3","#2166ac"], | |
9: ["#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac"], | |
10: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"], | |
11: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"] | |
},RdGy: { | |
3: ["#ef8a62","#ffffff","#999999"], | |
4: ["#ca0020","#f4a582","#bababa","#404040"], | |
5: ["#ca0020","#f4a582","#ffffff","#bababa","#404040"], | |
6: ["#b2182b","#ef8a62","#fddbc7","#e0e0e0","#999999","#4d4d4d"], | |
7: ["#b2182b","#ef8a62","#fddbc7","#ffffff","#e0e0e0","#999999","#4d4d4d"], | |
8: ["#b2182b","#d6604d","#f4a582","#fddbc7","#e0e0e0","#bababa","#878787","#4d4d4d"], | |
9: ["#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d"], | |
10: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"], | |
11: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"] | |
},RdYlBu: { | |
3: ["#fc8d59","#ffffbf","#91bfdb"], | |
4: ["#d7191c","#fdae61","#abd9e9","#2c7bb6"], | |
5: ["#d7191c","#fdae61","#ffffbf","#abd9e9","#2c7bb6"], | |
6: ["#d73027","#fc8d59","#fee090","#e0f3f8","#91bfdb","#4575b4"], | |
7: ["#d73027","#fc8d59","#fee090","#ffffbf","#e0f3f8","#91bfdb","#4575b4"], | |
8: ["#d73027","#f46d43","#fdae61","#fee090","#e0f3f8","#abd9e9","#74add1","#4575b4"], | |
9: ["#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4"], | |
10: ["#a50026","#d73027","#f46d43","#fdae61","#fee090","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"], | |
11: ["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"] | |
},Spectral: { | |
3: ["#fc8d59","#ffffbf","#99d594"], | |
4: ["#d7191c","#fdae61","#abdda4","#2b83ba"], | |
5: ["#d7191c","#fdae61","#ffffbf","#abdda4","#2b83ba"], | |
6: ["#d53e4f","#fc8d59","#fee08b","#e6f598","#99d594","#3288bd"], | |
7: ["#d53e4f","#fc8d59","#fee08b","#ffffbf","#e6f598","#99d594","#3288bd"], | |
8: ["#d53e4f","#f46d43","#fdae61","#fee08b","#e6f598","#abdda4","#66c2a5","#3288bd"], | |
9: ["#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd"], | |
10: ["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"], | |
11: ["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"] | |
},RdYlGn: { | |
3: ["#fc8d59","#ffffbf","#91cf60"], | |
4: ["#d7191c","#fdae61","#a6d96a","#1a9641"], | |
5: ["#d7191c","#fdae61","#ffffbf","#a6d96a","#1a9641"], | |
6: ["#d73027","#fc8d59","#fee08b","#d9ef8b","#91cf60","#1a9850"], | |
7: ["#d73027","#fc8d59","#fee08b","#ffffbf","#d9ef8b","#91cf60","#1a9850"], | |
8: ["#d73027","#f46d43","#fdae61","#fee08b","#d9ef8b","#a6d96a","#66bd63","#1a9850"], | |
9: ["#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850"], | |
10: ["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"], | |
11: ["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"] | |
},Accent: { | |
3: ["#7fc97f","#beaed4","#fdc086"], | |
4: ["#7fc97f","#beaed4","#fdc086","#ffff99"], | |
5: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0"], | |
6: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f"], | |
7: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17"], | |
8: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"] | |
},Dark2: { | |
3: ["#1b9e77","#d95f02","#7570b3"], | |
4: ["#1b9e77","#d95f02","#7570b3","#e7298a"], | |
5: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e"], | |
6: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02"], | |
7: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d"], | |
8: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"] | |
},Paired: { | |
3: ["#a6cee3","#1f78b4","#b2df8a"], | |
4: ["#a6cee3","#1f78b4","#b2df8a","#33a02c"], | |
5: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99"], | |
6: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c"], | |
7: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f"], | |
8: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00"], | |
9: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6"], | |
10: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a"], | |
11: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99"], | |
12: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"] | |
},Pastel1: { | |
3: ["#fbb4ae","#b3cde3","#ccebc5"], | |
4: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4"], | |
5: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6"], | |
6: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc"], | |
7: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd"], | |
8: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec"], | |
9: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"] | |
},Pastel2: { | |
3: ["#b3e2cd","#fdcdac","#cbd5e8"], | |
4: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4"], | |
5: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9"], | |
6: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae"], | |
7: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc"], | |
8: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"] | |
},Set1: { | |
3: ["#e41a1c","#377eb8","#4daf4a"], | |
4: ["#e41a1c","#377eb8","#4daf4a","#984ea3"], | |
5: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00"], | |
6: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33"], | |
7: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628"], | |
8: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf"], | |
9: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"] | |
},Set2: { | |
3: ["#66c2a5","#fc8d62","#8da0cb"], | |
4: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3"], | |
5: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854"], | |
6: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f"], | |
7: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494"], | |
8: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"] | |
},Set3: { | |
3: ["#8dd3c7","#ffffb3","#bebada"], | |
4: ["#8dd3c7","#ffffb3","#bebada","#fb8072"], | |
5: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3"], | |
6: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462"], | |
7: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69"], | |
8: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5"], | |
9: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9"], | |
10: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd"], | |
11: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5"], | |
12: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"] | |
}}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
function jetpack(d3) { | |
d3.selection.prototype.translate = function(xy) { | |
return this.attr('transform', function(d,i) { | |
return 'translate('+[typeof xy == 'function' ? xy(d,i) : xy]+')'; | |
}); | |
}; | |
d3.transition.prototype.translate = function(xy) { | |
return this.attr('transform', function(d,i) { | |
return 'translate('+[typeof xy == 'function' ? xy(d,i) : xy]+')'; | |
}); | |
}; | |
d3.selection.prototype.tspans = function(lines, lh) { | |
return this.selectAll('tspan') | |
.data(lines) | |
.enter() | |
.append('tspan') | |
.text(function(d) { return d; }) | |
.attr('x', 0) | |
.attr('dy', function(d,i) { return i ? lh || 15 : 0; }); | |
}; | |
d3.selection.prototype.append = | |
d3.selection.enter.prototype.append = function(name) { | |
var n = d3_parse_attributes(name), s; | |
//console.log(name, n); | |
name = n.attr ? n.tag : name; | |
name = d3_selection_creator(name); | |
s = this.select(function() { | |
return this.appendChild(name.apply(this, arguments)); | |
}); | |
return n.attr ? s.attr(n.attr) : s; | |
}; | |
d3.selection.prototype.insert = | |
d3.selection.enter.prototype.insert = function(name, before) { | |
var n = d3_parse_attributes(name), s; | |
name = n.attr ? n.tag : name; | |
name = d3_selection_creator(name); | |
before = d3_selection_selector(before); | |
s = this.select(function() { | |
return this.insertBefore(name.apply(this, arguments), before.apply(this, arguments) || null); | |
}); | |
return n.attr ? s.attr(n.attr) : s; | |
}; | |
var d3_parse_attributes_regex = /([\.#])/g; | |
function d3_parse_attributes(name) { | |
if (typeof name === "string") { | |
var attr = {}, | |
parts = name.split(d3_parse_attributes_regex), p; | |
name = parts.shift(); | |
while ((p = parts.shift())) { | |
if (p == '.') attr['class'] = attr['class'] ? attr['class'] + ' ' + parts.shift() : parts.shift(); | |
else if (p == '#') attr.id = parts.shift(); | |
} | |
return attr.id || attr['class'] ? { tag: name, attr: attr } : name; | |
} | |
return name; | |
} | |
function d3_selection_creator(name) { | |
return typeof name === "function" ? name : (name = d3.ns.qualify(name)).local ? function() { | |
return this.ownerDocument.createElementNS(name.space, name.local); | |
} : function() { | |
return this.ownerDocument.createElementNS(this.namespaceURI, name); | |
}; | |
} | |
function d3_selection_selector(selector) { | |
return typeof selector === "function" ? selector : function() { | |
return this.querySelector(selector); | |
}; | |
} | |
d3.wordwrap = function(line, maxCharactersPerLine) { | |
var w = line.split(' '), | |
lines = [], | |
words = [], | |
maxChars = maxCharactersPerLine || 40, | |
l = 0; | |
w.forEach(function(d) { | |
if (l+d.length > maxChars) { | |
lines.push(words.join(' ')); | |
words.length = 0; | |
l = 0; | |
} | |
l += d.length; | |
words.push(d); | |
}); | |
if (words.length) { | |
lines.push(words.join(' ')); | |
} | |
return lines; | |
}; | |
d3.ascendingKey = function(key) { | |
return typeof key == 'function' ? function (a, b) { | |
return key(a) < key(b) ? -1 : key(a) > key(b) ? 1 : key(a) >= key(b) ? 0 : NaN; | |
} : function (a, b) { | |
return a[key] < b[key] ? -1 : a[key] > b[key] ? 1 : a[key] >= b[key] ? 0 : NaN; | |
}; | |
}; | |
d3.descendingKey = function(key) { | |
return typeof key == 'function' ? function (a, b) { | |
return key(b) < key(a) ? -1 : key(b) > key(a) ? 1 : key(b) >= key(a) ? 0 : NaN; | |
} : function (a, b) { | |
return b[key] < a[key] ? -1 : b[key] > a[key] ? 1 : b[key] >= a[key] ? 0 : NaN; | |
}; | |
}; | |
d3.f = function(){ | |
var functions = arguments; | |
//convert all string arguments into field accessors | |
var i = 0, l = functions.length; | |
while (i < l) { | |
if (typeof(functions[i]) === 'string' || typeof(functions[i]) === 'number'){ | |
functions[i] = (function(str){ return function(d){ return d[str] }; })(functions[i]) | |
} | |
i++; | |
} | |
//return composition of functions | |
return function(d) { | |
var i=0, l = functions.length; | |
while (i++ < l) d = functions[i-1].call(this, d); | |
return d; | |
}; | |
}; | |
// store d3.f as convenient unicode character function (alt-f on macs) | |
if (!window.hasOwnProperty('ƒ')) window.ƒ = d3.f; | |
} | |
if (typeof d3 === 'object' && d3.version) jetpack(d3); | |
else if (typeof define === 'function' && define.amd) { | |
define(['d3'], jetpack); | |
} | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d3.conventions = function(c){ | |
c = c || {} | |
c.width = c.width || 900 | |
c.height = c.height || 500 | |
c.margin = c.margin || {top: 20, right: 20, bottom: 20, left: 45} | |
c.parentSel = c.parentSel || d3.select('body') | |
c.svg = c.svg || c.parentSel.append("svg") | |
.attr("width", c.width + c.margin.left + c.margin.right) | |
.attr("height", c.height + c.margin.top + c.margin.bottom) | |
.append("g") | |
.attr("transform", "translate(" + c.margin.left + "," + c.margin.top + ")") | |
c.color = c.color || d3.scale.category10() | |
c.x = c.x || d3.scale.linear().range([0, c.width]) | |
c.y = c.y || d3.scale.linear().range([c.height, 0]) | |
c.rScale = c.rScale || d3.scale.sqrt().range([5, 20]) | |
c.line = c.line || d3.svg.line() | |
c.xAxis = c.xAxis || d3.svg.axis().scale(c.x).orient("bottom"); | |
c.yAxis = c.yAxis || d3.svg.axis().scale(c.y).orient("left") | |
c.drawAxis = function(){ | |
c.svg.append("g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(0," + c.height + ")") | |
.call(c.xAxis); | |
c.svg.append("g") | |
.attr("class", "y axis") | |
.call(c.yAxis); | |
} | |
return c | |
} | |
d3.attachTooltip = function(sel, fieldFns){ | |
sel | |
.on('mouseover.attachTooltip', ttDisplay) | |
.on('mousemove.attachTooltip', ttMove) | |
.on('mouseout.attachTooltip', ttHide) | |
var d = sel.datum() | |
fieldFns = fieldFns || d3.keys(d) | |
.filter(function(str){ | |
return (typeof d[str] != 'object') && (d[str] != 'array') | |
}) | |
.map(function(str){ | |
return function(d){ return str + ': <b>' + d[str] + '</b>'} }) | |
function ttDisplay(d){ | |
d3.select('.tooltip') | |
.classed('tooltip-hidden', false) | |
.html('') | |
.dataAppend(fieldFns, 'div') | |
.html(function(fn){ return fn(d) }) | |
d3.select(this).classed('tooltipped', true) | |
} | |
function ttMove(d){ | |
var tt = d3.select('.tooltip') | |
if (!tt.size()) return | |
var e = d3.event, | |
x = e.clientX, | |
y = e.clientY, | |
doctop = (window.scrollY)? window.scrollY : (document.documentElement && document.documentElement.scrollTop)? document.documentElement.scrollTop : document.body.scrollTop; | |
n = tt.node(), | |
nBB = n.getBoundingClientRect() | |
tt.style('top', (y+doctop-nBB.height-18)+"px"); | |
tt.style('left', Math.min(Math.max(0, (x-nBB.width/2)), window.innerWidth - nBB.width)+"px"); | |
} | |
function ttHide(d){ | |
d3.select('.tooltip').classed('tooltip-hidden', true); | |
d3.selectAll('.tooltipped').classed('tooltipped', false) | |
} | |
} | |
d3.selection.prototype.dataAppend = function(data, name){ | |
return this.selectAll(name) | |
.data(data).enter() | |
.append(name) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.state rect { | |
fill: #dedede; | |
} | |
.state text { | |
font: 12px sans-serif; | |
text-anchor: middle; | |
} | |
.state--selected rect { | |
fill: black; | |
} | |
.state--selected text { | |
fill: white; | |
} | |
.bar{ | |
fill: darkgrey; | |
} | |
text.state { | |
font: 14px sans-serif; | |
pointer-events: none; | |
text-shadow: 0 1px 0 #fff, 1px 0 0 #fff, 0 -1px 0 #fff, -1px 0 0 #fff; | |
text-anchor: middle; | |
} | |
.axis line, | |
.axis path { | |
fill: none; | |
stroke: #000; | |
shape-rendering: crispEdges; | |
} | |
.axis{ | |
font: 12px sans-serif; | |
} | |
div.tooltip { | |
top: -1000px; | |
position: absolute; | |
padding: 10px; | |
background: rgba(255, 255, 255, .90); | |
border: 1px solid lightgray; | |
pointer-events: none; | |
} | |
.tooltip-hidden{ | |
opacity: 0; | |
} | |
</style> | |
<div class='tooltip'></div> | |
<script id="grid" type="text/plain"> | |
ME | |
WI VT NH | |
WA ID MT ND MN IL MI NY MA | |
OR NV WY SD IA IN OH PA NJ CT RI | |
CA UT CO NE MO KY WV VA MD DE | |
AZ NM KS AR TN NC SC | |
OK LA MS AL GA | |
HI AK TX FL | |
</script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
<script src="http://www.bloomberg.com/graphics/assets/js/vendor/lodash.underscore.min.js?"></script> | |
<script src='d3-jetpack.js'></script> | |
<script src='d3-starterkit.js'></script> | |
<script src='colorbrewer.js'></script> | |
<script src='script.js'></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var abvToName = { | |
"AL": "Alabama", | |
"AK": "Alaska", | |
"AS": "American Samoa", | |
"AZ": "Arizona", | |
"AR": "Arkansas", | |
"CA": "California", | |
"CO": "Colorado", | |
"CT": "Connecticut", | |
"DE": "Delaware", | |
"DC": "Dist. of Col.", | |
"FM": "Federated States Of Micronesia", | |
"FL": "Florida", | |
"GA": "Georgia", | |
"GU": "Guam", | |
"HI": "Hawaii", | |
"ID": "Idaho", | |
"IL": "Illinois", | |
"IN": "Indiana", | |
"IA": "Iowa", | |
"KS": "Kansas", | |
"KY": "Kentucky", | |
"LA": "Louisiana", | |
"ME": "Maine", | |
"MH": "Marshall Islands", | |
"MD": "Maryland", | |
"MA": "Massachusetts", | |
"MI": "Michigan", | |
"MN": "Minnesota", | |
"MS": "Mississippi", | |
"MO": "Missouri", | |
"MT": "Montana", | |
"NE": "Nebraska", | |
"NV": "Nevada", | |
"NH": "New Hampshire", | |
"NJ": "New Jersey", | |
"NM": "New Mexico", | |
"NY": "New York", | |
"NC": "North Carolina", | |
"ND": "North Dakota", | |
"MP": "Northern Mariana Islands", | |
"OH": "Ohio", | |
"OK": "Oklahoma", | |
"OR": "Oregon", | |
"PW": "Palau", | |
"PA": "Pennsylvania", | |
"PR": "Puerto Rico", | |
"RI": "Rhode Island", | |
"SC": "South Carolina", | |
"SD": "South Dakota", | |
"TN": "Tennessee", | |
"TX": "Texas", | |
"UT": "Utah", | |
"VT": "Vermont", | |
"VI": "Virgin Islands", | |
"VA": "Virginia", | |
"WA": "Washington", | |
"WV": "West Virginia", | |
"WI": "Wisconsin", | |
"WY": "Wyoming" | |
} | |
var states = [] | |
d3.select("#grid").text().split("\n").forEach(function(line, i) { | |
var re = /\w+/g, m; | |
while (m = re.exec(line)) states.push({ | |
name: m[0], | |
x: m.index / 3, | |
y: i, | |
fullName: abvToName[m[0]] | |
}); | |
}); | |
d3.csv('byState.csv', function(stateData){ | |
flatData = [] | |
stateData.forEach(function(d){ | |
var values = d3.entries(d).filter(function(d, i){ | |
d.value = +d.value.replace(',', '').replace(',', '') | |
return d.key != 'state' && i > -10 | |
}) | |
var total = d3.sum(values, ƒ('value')) | |
var prevPercent = 0 | |
values.forEach(function(d, i){ | |
d.percent = d.value/total | |
prevPercent += d.percent | |
d.prevPercent = prevPercent | |
d.i = i | |
flatData.push(d) | |
}) | |
var m = _.findWhere(states, {fullName: d.state.trim()}) | |
if (!m) return | |
m.values = values | |
m.yPercent = _.findWhere(values, {key: '35-39'}).prevPercent | |
m.oPercent = 1 - _.findWhere(values, {key: '70-74'}).prevPercent | |
}) | |
d3.select('body').append('h3').text('Percent Old, Middle Aged, and Young Drives') | |
var svg = d3.select("body").append('svg') | |
.attr({width: 960, height: 500}), | |
width = +svg.attr("width"), | |
height = +svg.attr("height"); | |
var gridWidth = d3.max(states, function(d) { return d.x; }) + 1, | |
gridHeight = d3.max(states, function(d) { return d.y; }) + 1, | |
cellSize = 60, | |
smCellSize = cellSize - 10 | |
var state = svg.append("g") | |
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")") | |
.selectAll(".state") | |
.data(states) | |
.enter().append("g.state") | |
.attr("transform", function(d) { | |
return "translate(" + (d.x - gridWidth / 2) * cellSize + "," + (d.y - gridHeight / 2) * cellSize + ")"; }); | |
state.append("rect") | |
.attr("x", -cellSize / 2) | |
.attr("y", -cellSize / 2) | |
.attr("width", cellSize) | |
.attr("height", cellSize); | |
state.append('g').translate([-smCellSize/2, smCellSize/2]) | |
.dataAppend(ƒ('values'), 'rect.bar') | |
.attr('width', smCellSize) | |
.attr('height', function(d){ return d.percent*smCellSize }) | |
.attr('y', function(d){ return -d.prevPercent*smCellSize }) | |
.style('fill', function(d, i){ return colorbrewer.Purples[3][Math.round(i/5)] }) | |
state.append("text") | |
.attr("dy", ".35em") | |
.text(function(d) { return d.name; }); | |
d3.select('body').append('h3').text('Percent Old Drivers') | |
var svg = d3.select("body").append('svg') | |
.attr({width: 960, height: 500}), | |
width = +svg.attr("width"), | |
height = +svg.attr("height"); | |
var gridWidth = d3.max(states, function(d) { return d.x; }) + 1, | |
gridHeight = d3.max(states, function(d) { return d.y; }) + 1, | |
cellSize = 60, | |
smCellSize = cellSize - 4 | |
var state = svg.append("g") | |
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")") | |
.selectAll(".state") | |
.data(states) | |
.enter().append("g.state") | |
.attr("transform", function(d) { | |
return "translate(" + (d.x - gridWidth / 2) * cellSize + "," + (d.y - gridHeight / 2) * cellSize + ")"; }); | |
var underColor = d3.scale.quantile() | |
.domain(states.map(ƒ('oPercent'))) | |
.range(colorbrewer.Purples[5]) | |
state.append("rect") | |
.attr("x", -smCellSize / 2) | |
.attr("y", -smCellSize / 2) | |
.attr("width", smCellSize) | |
.attr("height", smCellSize) | |
.style('fill', ƒ('oPercent', underColor)) | |
state.append("text") | |
.attr("dy", ".35em") | |
.text(function(d) { return d.name; }); | |
d3.select('body').append('h3').text('Percent Young Drivers') | |
var svg = d3.select("body").append('svg') | |
.attr({width: 960, height: 500}), | |
width = +svg.attr("width"), | |
height = +svg.attr("height"); | |
var gridWidth = d3.max(states, function(d) { return d.x; }) + 1, | |
gridHeight = d3.max(states, function(d) { return d.y; }) + 1, | |
cellSize = 60, | |
smCellSize = cellSize - 4 | |
var state = svg.append("g") | |
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")") | |
.selectAll(".state") | |
.data(states) | |
.enter().append("g.state") | |
.attr("transform", function(d) { | |
return "translate(" + (d.x - gridWidth / 2) * cellSize + "," + (d.y - gridHeight / 2) * cellSize + ")"; }); | |
var underColor = d3.scale.quantile() | |
.domain(states.map(ƒ('yPercent'))) | |
.range(colorbrewer.Purples[5]) | |
state.append("rect") | |
.attr("x", -smCellSize / 2) | |
.attr("y", -smCellSize / 2) | |
.attr("width", smCellSize) | |
.attr("height", smCellSize) | |
.style('fill', ƒ('yPercent', underColor)) | |
state.append("text") | |
.attr("dy", ".35em") | |
.text(function(d) { return d.name; }); | |
d3.select('body').append('h3').text('Percent Young Drivers v. Percent Old Drivers') | |
var c = d3.conventions() | |
c.x.domain(d3.extent(states, ƒ('yPercent'))) | |
c.y.domain(d3.extent(states, ƒ('oPercent'))) | |
c.drawAxis() | |
c.svg.dataAppend(states, 'text.state') | |
.text(ƒ('name')) | |
.attr('x', ƒ('yPercent', c.x)) | |
.attr('y', ƒ('oPercent', c.y)) | |
.attr('dy', '.33em') | |
d3.select('body').append('h3').text('Outliers By Age') | |
var byAge = d3.nest().key(ƒ('i')).map(flatData) | |
d3.values(byAge).forEach(function(d){ | |
var mean = d3.mean(d, ƒ('percent')) | |
d.forEach(function(d){ d.ageRatio = d.percent/mean }) | |
var maxAgeDiff = d3.max(d, ƒ('ageRatio', Math.abs)) | |
var minAgeDiff = d3.min(d, ƒ('ageRatio', Math.abs)) | |
var color = d3.scale.linear() | |
.domain([minAgeDiff, 1, maxAgeDiff]) | |
.range(['red', 'yellow', 'green']) | |
var num = d3.scale.linear() | |
.domain([minAgeDiff, 1, maxAgeDiff]) | |
.range([-1, 0, 1]) | |
d.forEach(function(d){ | |
d.ageRatioColor = color(d.ageRatio) | |
d.ageRatioNum = num(d.ageRatio) | |
}) | |
}) | |
states.forEach(function(state){ | |
// state.maxGroupI = _.sortBy(state.values, 'ageRatioNum')[0].i | |
state.maxGroupI = _.last(_.sortBy(state.values, 'ageRatioNum')).i | |
// state.maxGroupI = d3.sum(state.values.map(function(d){ | |
// return d.i*d.percent*d.percent*d.percent })) | |
}) | |
var c = d3.conventions({height: 800}) | |
c.x.domain([0, states[0].values.length]) | |
c.y.domain([0, states.length]) | |
stateGs = c.svg.dataAppend(_.sortBy(states, 'maxGroupI'), 'g') | |
.translate(function(d, i){ return [0, c.y(i)] }) | |
stateGs.dataAppend(ƒ('values'), 'rect') | |
.attr('height', c.y(0) - c.y(1)) | |
.attr('width', c.x(1) - c.x(0)) | |
.attr('x', function(d, i){ return c.x(i) }) | |
.attr('fill', ƒ('ageRatioColor')) | |
.call(d3.attachTooltip) | |
stateGs.append('text') | |
.text(ƒ('name')) | |
.attr('dy', '.76em') | |
.style('font-family', 'monospace') | |
d3.select(self.frameElement).style("height", innerHeight + "px"); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment