Skip to content

Instantly share code, notes, and snippets.

@mph006
Last active August 29, 2015 14:25
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 mph006/478c2118af5d256a1f3d to your computer and use it in GitHub Desktop.
Save mph006/478c2118af5d256a1f3d to your computer and use it in GitHub Desktop.
Historical Income by Country and Income Percentile - D3 update
dataset cop5 cop10 cop20 cop30 cop40 cop50 cop60 cop70 cop80 cop90 cop95
LIS - Australia 1981 6,910 8,290 10,900 13,232 15,207 17,427 19,965 23,055 26,945 32,439 37,458
LIS - Australia 1985 6,864 8,222 10,534 12,838 14,984 17,389 20,013 22,838 26,724 32,491 38,118
LIS - Australia 1989 6,555 8,190 10,714 12,931 15,138 17,559 20,412 23,613 27,692 33,881 39,931
LIS - Australia 1995 6,551 7,776 9,569 11,541 13,660 16,167 18,911 21,923 25,849 31,291 37,390
LIS - Australia 2001 7,002 8,474 10,499 12,870 15,252 18,113 21,229 24,532 28,688 35,978 42,543
LIS - Australia 2003 7,090 8,583 10,916 13,247 15,823 18,358 21,573 25,059 29,607 36,399 42,960
LIS - Austria 1987 8,818 11,154 13,814 16,036 18,019 19,815 21,842 24,269 27,302 32,176 36,895
LIS - Austria 1994 8,744 11,032 14,414 16,830 18,950 21,226 23,839 27,461 31,145 38,340 45,645
LIS - Austria 1995 5,813 8,961 11,942 14,097 16,390 18,631 20,942 24,030 27,792 33,432 38,777
LIS - Austria 1997 8,586 10,829 13,929 16,068 18,413 20,523 23,007 26,031 29,859 36,451 41,836
LIS - Austria 2000 9,807 11,901 14,764 17,103 19,514 21,797 24,200 27,115 30,846 37,525 45,149
LIS - Austria 2004 10,510 12,808 15,882 18,443 20,657 23,163 25,577 28,804 33,610 41,399 50,716
LIS - Belgium 1985 7,718 8,920 10,524 11,821 13,368 14,987 16,559 18,351 20,624 24,345 28,044
LIS - Belgium 1988 7,956 9,182 10,900 12,386 14,038 15,623 17,307 19,082 21,470 25,466 29,779
LIS - Belgium 1992 8,287 9,942 11,717 13,256 15,020 16,673 18,524 20,693 22,948 26,988 31,007
LIS - Belgium 1995 8,312 9,864 12,354 14,418 16,648 19,092 21,067 23,756 26,680 31,916 38,511
LIS - Belgium 1997 8,188 9,951 12,539 14,510 16,448 18,636 21,066 23,636 26,803 31,748 37,025
LIS - Belgium 2000 8,593 10,531 12,883 15,249 17,692 20,037 22,485 24,887 28,446 34,850 42,283
LIS - Canada 1981 7,361 9,799 13,442 16,536 19,053 21,729 24,560 28,077 32,540 39,682 45,965
LIS - Canada 1987 7,961 10,531 14,050 16,861 19,617 22,308 25,101 28,651 33,034 41,009 48,274
LIS - Canada 1991 8,175 10,680 14,254 16,825 19,515 22,160 25,195 28,618 33,163 40,336 47,659
LIS - Canada 1994 8,117 10,575 14,001 16,740 19,472 22,171 25,148 28,801 33,449 40,936 47,897
LIS - Canada 1997 7,643 10,285 13,689 16,435 19,316 22,107 25,179 28,805 33,476 41,192 48,710
LIS - Canada 1998 7,600 10,070 13,605 16,563 19,515 22,545 25,749 29,598 34,430 42,738 51,499
LIS - Canada 2000 7,696 10,307 13,782 16,570 19,430 22,335 25,600 29,575 34,786 43,176 52,213
LIS - Canada 2004 7,904 10,657 14,341 17,644 20,678 23,845 27,505 31,516 37,156 46,665 56,607
LIS - Canada 2007 9,171 12,062 15,849 19,227 22,419 25,903 29,708 34,170 40,175 50,244 61,155
LIS - Canada 2010 9,445 12,239 15,966 19,649 23,171 26,762 30,518 35,180 41,509 51,273 62,732
LIS - Denmark 1987 7,976 9,387 11,939 14,516 16,834 18,798 20,564 22,655 25,313 30,232 35,865
LIS - Denmark 1992 8,236 9,901 12,066 14,214 16,354 18,213 20,115 22,122 24,420 28,364 32,132
LIS - Denmark 1995 9,668 11,218 13,337 15,521 17,572 19,466 21,287 23,275 25,878 29,976 34,058
LIS - Denmark 2000 10,148 11,635 13,921 16,354 18,576 20,589 22,574 24,803 27,548 31,995 36,574
LIS - Denmark 2004 10,539 12,160 14,512 17,027 19,411 21,624 23,734 26,142 29,173 33,786 38,523
LIS - Estonia 2000 1,730 2,258 2,961 3,585 4,235 4,930 5,828 6,865 8,353 11,281 14,624
LIS - Estonia 2004 2,162 2,963 3,870 4,705 5,550 6,529 7,527 8,986 11,024 14,179 18,712
LIS - Estonia 2007 3,737 4,575 5,971 7,302 8,734 10,129 11,596 13,430 16,033 20,650 24,837
LIS - Estonia 2010 2,980 4,205 5,417 6,551 7,632 8,944 10,448 12,351 14,672 18,754 23,029
LIS - Finland 1987 7,364 8,721 10,571 12,053 13,533 14,793 16,093 17,581 19,391 22,375 25,492
LIS - Finland 1991 7,933 9,548 11,792 13,458 14,921 16,240 17,789 19,564 21,600 24,963 28,475
LIS - Finland 1995 7,624 8,904 10,627 11,994 13,323 14,567 15,936 17,495 19,629 22,938 26,439
LIS - Finland 2000 7,978 9,158 11,014 12,751 14,467 16,180 17,985 19,880 22,470 26,862 32,181
LIS - Finland 2004 8,596 10,073 12,367 14,324 16,311 18,265 20,227 22,747 25,921 31,223 36,664
LIS - Finland 2007 8,946 10,612 13,131 15,649 17,892 19,950 22,215 24,868 28,049 34,074 40,736
LIS - Finland 2010 9,379 10,996 13,523 15,895 18,195 20,430 22,847 25,571 29,160 34,904 41,230
LIS - France 1978 5,045 6,853 9,011 10,454 12,129 13,915 15,779 18,177 21,494 26,885 32,418
LIS - France 1984 4,121 7,068 9,834 11,606 13,406 15,227 17,201 19,651 22,818 28,390 34,808
LIS - France 1989 6,504 8,372 10,464 12,341 14,160 15,955 17,995 20,385 23,406 28,993 35,443
LIS - France 1994 7,696 9,424 11,826 13,709 15,601 17,508 19,834 22,704 26,343 33,369 40,922
LIS - France 2000 7,972 9,627 11,905 13,920 15,779 17,648 19,900 22,643 26,563 33,225 40,365
LIS - France 2005 7,815 9,609 12,302 14,492 16,461 18,411 20,608 23,394 26,907 33,905 41,392
LIS - Germany 1981 8,961 10,631 12,762 14,643 16,276 18,114 20,329 22,900 25,951 30,674 36,378
LIS - Germany 1983 10,101 12,152 14,723 16,801 18,880 21,151 23,700 26,737 30,873 37,779 45,712
LIS - Germany 1984 7,731 9,581 11,946 13,982 15,827 17,715 19,801 22,073 25,038 30,413 36,717
LIS - Germany 1989 9,583 11,413 13,859 15,978 18,079 19,902 22,331 25,007 28,538 34,374 40,604
LIS - Germany 1994 8,512 10,629 13,309 15,494 17,385 19,472 21,811 24,704 28,650 35,354 42,693
LIS - Germany 2000 9,142 11,552 14,589 16,940 18,902 20,969 23,361 26,359 30,338 37,499 45,177
LIS - Germany 2004 8,950 11,084 14,103 16,513 18,705 20,953 23,373 26,351 30,592 38,188 46,901
LIS - Germany 2007 8,841 10,858 13,785 16,192 18,333 20,562 23,110 26,096 30,181 37,779 47,612
LIS - Germany 2010 8,554 10,612 13,554 16,033 18,364 20,906 23,702 26,584 30,560 38,603 46,802
LIS - Greece 1995 2,846 4,299 6,280 7,623 9,199 10,821 12,544 14,891 17,439 23,020 29,153
LIS - Greece 2000 3,852 5,273 7,082 8,823 10,558 12,173 14,429 16,827 19,964 24,917 31,514
LIS - Greece 2004 5,327 6,830 8,973 11,029 12,801 14,737 17,159 20,114 23,703 29,873 37,905
LIS - Greece 2007 5,937 7,662 9,813 11,724 13,762 15,975 18,228 20,958 25,048 31,498 38,485
LIS - Greece 2010 4,925 6,543 8,521 10,459 12,239 14,527 16,809 19,202 22,606 28,683 35,400
LIS - Ireland 1987 3,959 4,647 5,643 6,826 8,162 9,405 10,923 12,827 15,439 19,640 23,678
LIS - Ireland 1994 5,439 6,028 7,442 8,813 10,498 12,482 14,894 17,378 20,762 26,161 31,438
LIS - Ireland 1995 5,457 6,124 7,596 9,157 10,918 12,976 15,122 17,694 21,105 26,887 33,986
LIS - Ireland 1996 5,765 6,425 8,046 9,873 11,659 13,812 16,230 19,122 22,243 27,817 34,569
LIS - Ireland 2000 6,744 7,606 10,219 13,203 15,556 18,144 20,613 23,996 27,471 34,051 40,173
LIS - Ireland 2004 7,827 9,262 11,812 14,530 17,497 20,547 23,985 27,463 31,833 39,588 47,052
LIS - Ireland 2007 9,672 11,200 13,877 16,722 19,721 22,755 25,626 29,566 34,749 43,026 51,151
LIS - Ireland 2010 8,196 9,902 12,307 14,488 16,769 19,399 22,310 25,621 29,984 37,206 44,415
LIS - Israel 1986 4,185 4,931 6,339 7,607 8,933 10,397 11,976 14,118 16,800 21,196 25,458
LIS - Israel 1992 4,895 6,076 7,600 9,094 10,612 12,216 14,277 16,676 19,793 25,029 29,816
LIS - Israel 1997 4,359 5,337 7,098 8,746 10,351 12,366 14,517 17,104 20,557 25,961 31,839
LIS - Israel 2001 4,968 5,925 7,585 9,540 11,568 13,745 16,422 19,313 23,034 29,689 36,315
LIS - Israel 2005 3,858 5,068 6,922 8,890 11,205 13,528 16,060 19,302 23,499 30,502 38,134
LIS - Israel 2007 4,258 5,569 7,575 9,572 12,052 14,646 17,700 20,973 25,480 32,947 41,194
LIS - Israel 2010 4,233 5,562 7,531 9,539 12,187 15,174 18,301 21,801 26,339 34,930 42,774
LIS - Italy 1986 4,711 6,035 7,784 9,132 10,567 12,328 14,258 16,412 19,526 24,408 28,830
LIS - Italy 1987 4,653 6,251 8,000 9,582 11,189 13,081 15,044 17,867 21,831 28,097 34,415
LIS - Italy 1989 5,959 7,379 9,171 10,805 12,851 14,662 16,776 19,720 23,286 28,974 35,243
LIS - Italy 1991 6,247 7,470 9,274 11,199 13,231 15,183 17,418 19,815 23,156 28,192 34,426
LIS - Italy 1993 4,241 6,152 8,064 9,897 11,778 13,997 16,443 19,132 22,713 28,810 36,049
LIS - Italy 1995 4,054 5,871 7,995 9,710 11,555 13,682 15,881 18,732 21,797 27,409 34,054
LIS - Italy 1998 4,294 6,161 8,535 10,316 12,269 14,394 16,682 19,409 23,151 29,037 37,420
LIS - Italy 2000 4,767 6,474 8,757 10,485 12,503 14,613 16,957 19,815 23,206 29,156 37,228
LIS - Italy 2004 5,155 6,853 8,973 10,819 12,693 14,997 17,277 20,179 23,727 30,432 38,086
LIS - Italy 2008 5,910 7,370 9,428 11,259 13,321 15,636 18,034 20,838 24,514 31,126 38,674
LIS - Italy 2010 5,011 6,944 9,197 11,007 12,922 15,164 17,456 20,109 23,817 30,211 37,558
LIS - Luxembourg 1985 8,882 10,043 11,969 13,644 15,428 17,007 18,718 21,307 24,648 29,571 34,485
LIS - Luxembourg 1991 13,654 14,864 17,988 20,914 23,748 26,410 29,533 32,534 37,039 44,163 52,617
LIS - Luxembourg 1994 14,712 16,711 19,841 22,381 25,012 28,249 31,379 34,852 39,206 48,706 57,394
LIS - Luxembourg 1997 13,300 15,603 19,129 22,259 25,318 28,022 31,527 35,481 41,387 50,811 60,190
LIS - Luxembourg 2000 13,970 17,082 20,634 23,661 26,599 29,916 34,109 38,604 44,627 55,699 66,150
LIS - Luxembourg 2004 15,231 18,016 23,716 27,013 30,417 34,260 38,311 43,498 49,997 63,024 76,497
LIS - Luxembourg 2007 15,191 18,619 22,997 27,028 30,098 34,174 38,785 43,237 49,589 61,922 76,912
LIS - Luxembourg 2010 15,875 18,729 22,852 26,166 29,796 33,755 38,776 44,083 49,902 62,370 71,988
LIS - Mexico 1989 962 1,356 1,938 2,494 3,051 3,734 4,494 5,528 7,298 10,661 14,862
LIS - Mexico 1992 952 1,360 2,007 2,602 3,192 3,875 4,748 6,011 8,026 12,008 18,577
LIS - Mexico 1994 998 1,333 1,938 2,557 3,200 3,933 4,887 6,100 8,145 12,764 18,734
LIS - Mexico 1996 795 1,075 1,540 1,990 2,463 3,022 3,707 4,658 6,211 9,206 13,691
LIS - Mexico 1998 693 995 1,528 2,037 2,599 3,245 4,037 5,144 6,856 10,372 15,035
LIS - Mexico 2000 898 1,236 1,841 2,436 3,118 3,850 4,862 6,070 8,072 12,435 17,954
LIS - Mexico 2002 972 1,338 2,018 2,619 3,281 4,004 4,834 6,136 8,076 12,132 17,679
LIS - Mexico 2004 979 1,473 2,234 2,819 3,461 4,239 5,108 6,498 8,392 12,428 17,897
LIS - Mexico 2008 1,140 1,807 2,885 3,821 4,807 5,921 7,276 8,993 11,554 16,492 22,641
LIS - Mexico 2010 1,021 1,740 2,812 3,722 4,602 5,584 6,733 8,172 10,320 14,581 20,000
LIS - Netherlands 1983 7,213 9,272 10,919 12,631 14,168 15,589 17,370 19,641 22,409 26,891 31,781
LIS - Netherlands 1987 8,689 9,970 11,464 13,126 14,681 16,238 18,043 20,286 22,943 27,501 31,756
LIS - Netherlands 1990 8,871 11,027 13,163 15,106 17,085 19,197 21,488 24,159 27,760 33,244 39,445
LIS - Netherlands 1993 7,412 9,999 12,360 14,399 16,209 18,230 20,520 23,154 26,557 31,450 35,654
LIS - Netherlands 1999 10,584 12,384 14,868 16,840 19,042 21,094 23,228 25,905 29,225 34,415 39,766
LIS - Netherlands 2004 9,601 12,023 14,606 16,703 18,756 20,887 23,317 26,069 29,933 36,281 43,278
LIS - Netherlands 2007 11,309 13,210 16,117 18,318 20,582 22,978 25,606 28,743 33,123 41,106 50,112
LIS - Netherlands 2010 11,254 13,159 15,866 18,283 20,480 22,665 25,432 28,574 32,792 39,949 47,481
LIS - Norway 1979 6,791 7,735 9,639 11,083 12,298 13,539 14,835 16,301 18,209 21,433 24,595
LIS - Norway 1986 8,430 10,264 12,956 15,035 16,822 18,560 20,388 22,744 25,513 30,126 34,851
LIS - Norway 1991 8,930 10,863 13,641 15,682 17,425 19,212 21,084 23,151 25,961 30,296 34,648
LIS - Norway 1995 9,729 11,828 15,034 17,111 18,876 20,661 22,493 24,805 27,589 31,813 36,801
LIS - Norway 2000 10,393 12,670 15,668 18,119 20,299 22,376 24,510 26,922 30,082 35,556 42,160
LIS - Norway 2004 10,898 13,543 16,918 19,553 21,958 24,196 26,432 29,070 32,747 38,798 46,112
LIS - Poland 1995 1,690 2,417 3,272 3,935 4,533 5,151 5,845 6,650 7,761 9,735 12,122
LIS - Poland 1999 2,577 3,262 4,173 4,910 5,594 6,313 7,055 7,965 9,242 11,541 14,094
LIS - Poland 2004 2,343 3,006 3,937 4,683 5,394 6,172 6,992 8,040 9,469 12,090 15,295
LIS - Poland 2007 3,016 3,829 4,889 5,719 6,540 7,430 8,440 9,651 11,415 14,464 18,269
LIS - Poland 2010 3,504 4,424 5,644 6,645 7,658 8,719 9,865 11,361 13,429 17,166 21,507
LIS - Spain 1980 3,366 4,396 5,756 7,072 8,308 9,518 10,863 12,563 14,950 19,198 23,695
LIS - Spain 1985 3,493 4,517 5,724 6,902 8,045 9,066 10,295 11,826 14,100 18,408 22,654
LIS - Spain 1990 4,637 5,849 7,453 8,869 10,284 11,694 13,447 15,501 18,271 23,105 28,338
LIS - Spain 1995 3,737 5,672 7,687 9,668 11,272 12,966 15,478 18,428 22,366 28,930 37,060
LIS - Spain 2000 5,677 7,271 9,621 11,700 13,952 16,406 19,027 22,414 26,468 34,072 41,837
LIS - Spain 2004 5,542 7,054 9,494 11,638 13,847 16,101 18,631 21,692 25,567 31,805 38,335
LIS - Spain 2007 6,138 7,976 10,615 13,025 15,247 17,823 20,331 23,499 27,443 34,457 41,371
LIS - Spain 2010 4,112 6,455 9,108 11,355 13,503 15,981 18,742 21,750 25,845 33,013 39,919
LIS - Sweden 1981 6,203 7,819 9,380 10,503 11,545 12,601 13,768 14,987 16,536 18,999 21,027
LIS - Sweden 1987 6,107 7,764 9,625 11,124 12,337 13,562 14,805 16,051 17,881 20,418 22,915
LIS - Sweden 1992 6,897 9,037 11,121 12,887 14,422 15,744 17,318 19,107 21,291 25,086 28,914
LIS - Sweden 1995 6,151 8,831 11,083 12,447 13,583 14,739 15,955 17,391 19,499 23,033 26,403
LIS - Sweden 2000 7,801 9,758 11,923 13,820 15,514 17,163 18,959 21,036 24,000 28,917 34,379
LIS - Sweden 2005 9,611 11,369 13,699 15,812 17,807 19,743 21,713 23,955 27,036 32,072 37,237
LIS - Switzerland 1982 10,261 12,975 16,305 18,742 21,074 23,830 26,505 29,936 34,516 44,014 58,217
LIS - Switzerland 1992 6,980 12,570 16,291 18,918 21,554 24,213 27,054 31,033 36,400 45,480 55,966
LIS - Switzerland 2000 10,978 13,140 16,329 19,164 21,689 24,175 27,037 31,012 36,215 43,919 53,265
LIS - Switzerland 2002 11,384 13,861 17,115 19,750 22,869 25,702 29,071 32,923 38,166 46,798 54,887
LIS - Switzerland 2004 10,504 13,299 16,839 19,549 22,209 24,755 27,541 31,084 36,033 43,642 50,709
LIS - United Kingdom 1979 5,683 6,716 8,416 10,022 11,554 13,072 14,810 16,901 19,461 23,382 27,212
LIS - United Kingdom 1986 5,421 6,718 8,180 9,673 11,315 13,128 15,215 17,556 20,710 25,516 30,523
LIS - United Kingdom 1991 5,678 6,766 8,594 10,693 12,980 15,323 17,888 21,051 25,325 31,581 38,294
LIS - United Kingdom 1994 6,646 7,761 9,493 11,325 13,428 15,813 18,565 21,888 26,284 33,491 41,771
LIS - United Kingdom 1995 5,814 7,143 8,945 10,767 12,998 15,554 18,239 21,472 25,407 32,648 41,260
LIS - United Kingdom 1999 6,871 8,300 10,436 12,714 15,241 17,997 21,073 24,989 30,028 38,771 48,306
LIS - United Kingdom 2004 8,418 10,348 13,051 15,546 18,409 21,355 24,832 29,071 34,925 45,641 57,624
LIS - United Kingdom 2007 6,810 9,008 12,719 16,021 19,238 22,631 26,572 31,091 37,203 47,559 59,428
LIS - United Kingdom 2010 6,781 9,162 12,569 15,734 18,730 21,990 25,677 29,924 35,883 46,754 58,795
LIS - United States 1979 7,143 9,726 13,762 17,312 20,541 23,583 27,024 30,981 35,931 43,946 51,871
LIS - United States 1986 6,753 9,187 13,168 17,101 20,759 24,267 28,403 33,162 39,504 49,365 59,514
LIS - United States 1991 6,674 8,996 13,008 16,706 20,417 24,189 28,356 33,107 39,207 49,226 58,986
LIS - United States 1994 6,503 8,954 13,000 16,569 20,159 24,054 28,434 33,559 40,109 51,504 64,090
LIS - United States 1997 7,142 9,799 13,838 17,488 21,331 25,413 29,852 35,024 41,983 54,422 68,912
LIS - United States 2000 7,809 10,641 14,914 18,994 23,079 27,320 31,990 37,161 44,422 57,430 73,551
LIS - United States 2004 7,226 10,396 14,932 18,960 23,269 27,559 32,405 38,156 45,590 58,657 73,921
LIS - United States 2007 7,285 10,423 14,932 19,142 23,432 27,970 33,039 38,891 46,689 60,544 77,663
LIS - United States 2010 6,410 9,645 14,378 18,396 22,559 27,058 32,212 38,072 45,801 59,356 74,768
<!DOCTYPE html>
<meta charset="utf-8">
<style type="text/css">
body {
font-family: arial, sans;
font-size: 13px;
margin: 10px auto;
width:1220px;
}
.line {
fill:none;
}
.axis text {
font-size: 12px;
fill: #777;
}
.axis path {
display: none;
}
.axis line {
stroke-width:.3px;
stroke: #dedede;
/*stroke-dasharray: 2px 2px;*/
}
.country-container {
display: inline-block;
margin-right:10px;
}
.info{
position: absolute;
top: 10px;
left: 250px;
}
.country-label{
position: absolute;
top:15px;
left:150px;
}
#countrySelect{
position: absolute;
top: 30px;
left:500px;
}
#decileSelect{
position: absolute;
top: 30px;
left:650px;
}
</style>
<body>
<div class="info"></div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" charset="utf-8"></script>
<script type="text/javascript">
var margin = {top: 20, right: 50, bottom: 20, left: 80};
var mapData;
var width = 900 - margin.left - margin.right,
height = 600 - margin.top - margin.bottom;
var xScale = d3.scale.linear()
.range([0,width]);
var yScale = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(xScale)
.tickSize(-height)
.tickPadding(8)
.tickFormat(d3.round)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(yScale)
.tickSize(-width)
.tickPadding(8)
.orient("left");
var container = d3.select("body")
.append("div")
.attr("class", "country-container");
var svg = container.append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
function fetchInt(string){
return +string.replace(",","");
}
function updateData(){
var countrySelect = document.getElementById('countrySelect');
var decileSelect = document.getElementById('decileSelect');
var country = countrySelect.options[countrySelect.selectedIndex].value;
var decile = decileSelect.options[decileSelect.selectedIndex].value;
var line = d3.svg.line()
.x(function(d) { return xScale(d.year); })
.y(function(d) { return yScale(d[decile]); });
d3.select(".country-label")
.text("Country: "+country+" : "+decile);
svg.selectAll(".line")
.datum(mapData[country])
.transition().duration(500)
.attr("d", line);
var circleData = svg.selectAll(".circle-container")
//Missing object constency here...
.data(mapData[country])
.attr("class","circle-container update");
circleData.enter()
.append("circle")
.attr("class","circle-container enter")
.attr("r",4)
svg.selectAll(".circle-container")
.style("fill","steelblue")
.transition()
.duration(500)
.attr("cx",function(d){return xScale(d.year); })
.attr("cy",function(d){return yScale(d[decile]); })
.style("opacity",1);
//Must know the svg element things are coming from (.svg), not a blanket d3.select()
//Must seperate data and enter and exit variables
circleData.exit()
.attr("class","circle-container exit")
.transition()
.duration(200)
.style("opacity",0)
.remove();
}
d3.tsv("all-countries.tsv", ready);
function ready(error, data) {
if (error) return console.warn(error);
data.forEach(function(d){
d.cop5 = fetchInt(d.cop5);
d.cop10 = fetchInt(d.cop10);
d.cop20 = fetchInt(d.cop20);
d.cop30 = fetchInt(d.cop30);
d.cop40 = fetchInt(d.cop40);
d.cop50 = fetchInt(d.cop50);
d.cop60 = fetchInt(d.cop60);
d.cop70 = fetchInt(d.cop70);
d.cop80 = fetchInt(d.cop80);
d.cop90 = fetchInt(d.cop90);
d.cop95 = fetchInt(d.cop95);
d.year = +d.dataset.split(" ")[d.dataset.split(" ").length-1];
d.country = d.dataset.replace(/[0-9]/g, "").replace("LIS - ","").trim();
});
xScale.domain(d3.extent(data,function(d){return d.year;}));
yScale.domain([d3.extent(data,function(d){return d.cop5;})[0],d3.extent(data,function(d){return d.cop95;})[1]]);
mapData = d3.nest()
.key(function(d){ return d.country;})
.map(data);
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + (height) + ")")
.call(xAxis)
.selectAll("g");
svg.append("g")
.attr("class", "y axis")
.attr("transform", "translate(" +10+ ",0)")
.call(yAxis);
var countryList = d3.set(data.map(function(d) { return d.country; })).values();
decileList = [];
for(var k in data[0]) (k.indexOf("cop")>-1)?decileList.push(k):"do nothing!";
d3.select("body")
.append("select")
.attr("class","drop-down-selector")
.attr("id","countrySelect")
.on("change",updateData)
.selectAll("option")
.data(countryList)
.enter().append("option")
.text(function(d) {return d;});
d3.select("body")
.append("select")
.attr("class","drop-down-selector")
.attr("id","decileSelect")
.on("change",updateData)
.selectAll("option")
.data(decileList)
.enter().append("option")
.text(function(d) {return d;});
container.append("h2")
.attr("class","country-label");
svg.append("path")
.attr("class", "line")
.style("stroke","steelblue");
updateData();
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment