Skip to content

Instantly share code, notes, and snippets.

@majomo
Created September 23, 2015 19:23
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 majomo/d2afa97d4b5d1e5696fe to your computer and use it in GitHub Desktop.
Save majomo/d2afa97d4b5d1e5696fe to your computer and use it in GitHub Desktop.
Bar with scale and axes
Geography Year Total_-_Regardless_of_Aboriginal_status_-_Household_Count Total_all_Average_Household_Income Total_-_Regardless_of_Aboriginal_status_-_Average_Shelter_Cost_($) Total_-_Regardless_of_Aboriginal_status_-_Average_STIR_(%) _Aboriginal_household_-_Household_Count _Aboriginal_household_-_Average_Household_Income_($) _Aboriginal_household_-_Average_Shelter_Cost_($) _Aboriginal_household_-_Average_STIR_(%) _Non-Aboriginal_household_-_Household Count _Non-Aboriginal_household_-_Average_Household_Income_($) _Non-Aboriginal_household_-_Average_Shelter_Cost_($) _Non-Aboriginal_household_-_Average_STIR_(%)
BRITISH COLUMBIA 1996 441745 36936 708 31.6 24040 31066 653 35.8 417705 37273 711 31.3
BRITISH COLUMBIA 2001 458680 41710 754 30.3 28910 34796 687 33.6 429765 42175 759 30.1
BRITISH COLUMBIA 2006 445340 45965.7 824.7 30.2 33275 39998.5 739.6 30.9 412070 46447.6 831.6 30.1
BRITISH COLUMBIA 2011 466650 55283 982 30.4 39035 46724 901 32.1 427615 56064 989 30.3
Alberni-Clayoquot 1996 2985 30405 541 31.9 410 25367 555 38.3 2575 31207 539 31
Alberni-Clayoquot 2001 3030 32376 558 30.5 720 29549 595 34.6 2310 33256 546 29.2
Alberni-Clayoquot 2006 2795 34808.5 590.2 28.5 540 32925.2 608.2 27.5 2260 35256.6 585.8 28.7
Alberni-Clayoquot 2011 3345 40198 757 30.6 620 32767 738 33.9 2720 41900 761 29.9
Bulkley-Nechako 1996 3015 37591 520 25.3 375 36591 501 23.9 2635 37733 522 25.5
Bulkley-Nechako 2001 2920 43099 581 24.2 500 42959 601 26.2 2420 43128 576 23.8
Bulkley-Nechako 2006 2795 46438.6 579.4 24.5 645 40197.9 585 24.5 2150 48320.4 576.4 24.5
Bulkley-Nechako 2011 2795 47967 655 25.6 650 46104 670 27.5 2145 48531 651 25
Capital 1996 45935 34675 711 32.7 1750 33041 690 34.5 44180 34740 711 32.6
Capital 2001 46620 38531 730 30.9 2030 34454 702 33.8 44590 38716 731 30.7
Capital 2006 48155 43753.2 817.2 30.7 2865 42415.9 788.1 30 45285 43838 819 30.7
Capital 2011 49215 50937 979 31.6 3550 46461 937 32.1 45665 51285 982 31.6
Cariboo 1996 5345 35006 553 28.5 680 30028 578 32.7 4665 35731 550 27.8
Cariboo 2001 5205 36991 587 29.2 845 32446 610 33.5 4360 37874 582 28.4
Cariboo 2006 4910 39932.2 583.8 26.1 1005 39603.6 640.9 28.6 3900 40017 569.8 25.4
Cariboo 2011 4765 45468 691 27.6 1240 42173 736 30.5 3525 46626 675 26.6
Central Coast 1996 235 44595 501 20.4 25 36634 449 26.2 210 45677 510 19.6
Central Coast 2001 215 39744 534 25.8 35 18823 715 47.3 175 44087 500 21.6
Central Coast 2006 150 43718.1 555.2 20.4 25 42020.7 0 0 125 44090.1 552.2 20.3
Central Coast 2011 95 42985 543 21.3 40 41047 474 21.5 55 44438 599 19
Central Kootenay 1996 4735 27902 535 31.9 280 30047 579 36.1 4455 27765 532 31.7
Central Kootenay 2001 5295 31622 582 32.1 240 30709 687 35.9 5055 31666 578 31.9
Central Kootenay 2006 4840 35546.4 626.6 30.5 315 38640.9 632.6 30 4525 35329 626.2 30.6
Central Kootenay 2011 4595 43404 758 28.8 450 46694 822 31.3 4140 43047 751 28.5
Central Okanagan 1996 13375 33191 698 33.7 645 31035 722 37.5 12735 33300 697 33.5
Central Okanagan 2001 14075 37794 732 31.5 745 29446 734 36.9 13325 38261 731 31.2
Central Okanagan 2006 13750 44019 870.7 32 980 41870.3 850.9 31 12770 44183.9 872.6 32.1
Central Okanagan 2011 15615 52243 1066 33.2 1520 52241 1040 32 14095 52243 1069 33.3
Columbia - Shuswap 1996 3970 32142 561 28.5 225 33306 600 32.8 3745 32073 559 28.2
Columbia - Shuswap 2001 4320 32618 591 30.4 300 31397 661 37.7 4015 32710 587 29.8
Columbia - Shuswap 2006 3705 39867 657.2 28.4 370 32966.8 638.5 31.8 3335 40639 658.3 28.1
Columbia - Shuswap 2011 3915 43380 799 30.2 475 34100 731 31.4 3435 44667 809 30.1
Comox Valley 2011 5735 44357 861 32.3 505 38567 884 35.8 5230 44918 859 31.9
Comox - Strathcona 1996 9325 34029 628 31.3 655 29039 630 37.8 8675 34406 628 30.8
Comox - Strathcona 2001 9320 35472 627 30.8 825 30380 642 36.8 8495 35967 625 30.2
Comox - Strathcona 2006 9165 39345.6 681 30.7 1100 34747.6 693.6 32.8 8065 39973 679.3 30.4
Cowichan Valley 1996 5745 30633 626 33.2 485 29919 653 38.8 5260 30699 623 32.7
Cowichan Valley 2001 5785 33800 633 32.3 700 28308 626 34.8 5080 34559 634 32
Cowichan Valley 2006 5620 37741.3 681 30.8 690 38130.9 678.9 28.3 4930 37686.9 681.3 31.1
Cowichan Valley 2011 5545 42312 825 31.3 770 39521 777 31.9 4770 42763 832 31.2
East Kootenay 1996 4960 31413 532 29.6 330 29397 575 32.3 4625 31558 529 29.5
East Kootenay 2001 4825 37063 593 28.1 365 40886 614 30.2 4465 36752 590 27.9
East Kootenay 2006 4535 39365.2 628 27.9 495 34169.1 584.8 29.5 4040 40000.8 633.4 27.7
East Kootenay 2011 4640 53855 781 27.6 655 48887 804 31 3985 54672 777 27
Fraser - Fort George 1996 8605 36488 631 29.2 1310 32277 644 34 7290 37244 629 28.4
Fraser - Fort George 2001 8715 38025 657 30.6 1585 34396 652 34.2 7135 38830 658 29.8
Fraser - Fort George 2006 8800 40446.9 650.9 28.2 1935 39550.4 658.4 29.7 6865 40699.7 648.8 27.8
Fraser - Fort George 2011 9110 45489 779 29.6 2050 39757 775 33.1 7060 47154 780 28.5
Fraser Valley 1996 19725 33268 670 32.8 1245 29865 676 39.1 18475 33497 669 32.4
Fraser Valley 2001 21640 37240 693 31 1595 32979 689 34.4 20040 37579 693 30.7
Fraser Valley 2006 21370 40353.9 761.9 30.8 2215 39059.9 778.2 32.3 19160 40503.5 760 30.7
Fraser Valley 2011 22005 48406 863 30.3 2640 42951 882 33 19360 49151 860 30
Greater Vancouver 1996 252735 39278 756 31.6 9895 31473 689 36.6 242840 39596 759 31.4
Greater Vancouver 2001 264970 45304 817 30 11085 37813 750 33.2 253880 45631 820 29.9
Greater Vancouver 2006 254440 49612.1 888.5 30.2 11500 41959.8 813.6 32.5 242940 49974.3 892.1 30.1
Greater Vancouver 2011 270405 60135 1048 30.1 13800 51152 994 32.1 256600 60618 1051 30
Kitimat - Stikine 1996 3250 40321 570 25.1 620 33805 568 30.1 2635 41849 572 23.9
Kitimat - Stikine 2001 2820 41869 631 28.2 740 32725 640 36 2085 45100 629 25.4
Kitimat - Stikine 2006 2700 40210.1 593.8 27.2 955 33607.7 619.3 31.2 1745 43816.4 577.9 24.9
Kitimat - Stikine 2011 2955 48905 695 28 1140 41892 682 30.4 1820 53290 703 26.5
Kootenay Boundary 1996 2650 27831 492 30.1 80 27578 478 33.8 2575 27839 493 30
Kootenay Boundary 2001 2605 30205 536 30.7 170 31604 547 29.4 2435 30108 536 30.8
Kootenay Boundary 2006 2260 34752.7 568.6 27.5 110 33951.4 604.2 33 2155 34793.5 566.7 27.3
Kootenay Boundary 2011 2230 44723 722 32.2 285 57263 804 28 1940 42872 710 32.8
Mount Waddington 1996 1405 47695 566 22.1 125 29656 707 41 1280 49421 553 20.3
Mount Waddington 2001 1280 44775 589 22.8 155 31298 611 33.7 1125 46627 586 21.2
Mount Waddington 2006 1045 43141.3 571.9 24 170 35889.6 538.6 26.8 875 44560.9 575.4 23.5
Mount Waddington 2011 990 48033 659 24.3 260 38380 604 26 730 51445 678 23.9
Nanaimo 1996 12095 31197 660 35 750 29108 705 39.7 11340 31335 657 34.7
Nanaimo 2001 12675 32061 642 33.3 970 27243 632 37.2 11710 32461 643 33
Nanaimo 2006 13190 37494.7 741.6 32.5 1385 38534.4 732.3 32.9 11810 37373.2 742.3 32.5
Nanaimo 2011 13095 44906 898 33.6 1455 43875 917 32 11640 45035 895 33.8
North Okanagan 1996 6170 29350 617 33.7 325 23975 631 39.5 5845 29649 616 33.4
North Okanagan 2001 7010 32110 635 32.2 580 27991 603 35.2 6430 32482 638 32
North Okanagan 2006 6785 36053.6 689.7 31.2 700 38462.1 708.6 28.5 6075 35774.9 686.9 31.5
North Okanagan 2011 6775 44939 867 32.3 680 40908 990 35.6 6095 45389 853 31.9
Northern Rockies 1996 615 47431 678 24.4 80 47483 698 32.9 535 47423 675 23.1
Northern Rockies 2001 525 57929 699 23.5 55 44336 731 31.8 470 59614 695 22.5
Northern Rockies 2006 550 66033.5 770.1 18.7 130 60864 717.2 17.8 415 67654.9 797 19.2
Northern Rockies 2011 490 71131 939 20.5 105 52531 917 26.2 380 76465 945 18.9
Okanagan - Similkameen 1996 8245 28391 571 32.3 465 23486 585 39.7 7775 28686 571 31.8
Okanagan - Similkameen 2001 8430 31498 630 32.3 510 32758 662 32.7 7920 31417 629 32.3
Okanagan - Similkameen 2006 7975 36631.9 714 31.8 550 41927 719.7 29.7 7430 36240.9 714.1 32
Okanagan - Similkameen 2011 7725 41637 860 33.5 630 39815 908 36.6 7100 41799 856 33.2
Peace River 1996 5645 42383 571 24 640 33936 532 30.3 5010 43459 576 23.1
Peace River 2001 5380 44217 640 25.8 1010 37914 636 29.6 4370 45672 640 24.9
Peace River 2006 5370 50903.6 755.5 25.6 1045 51173.2 742.5 26.4 4325 50838.7 757.8 25.4
Peace River 2011 5955 66874 958 26 1230 55837 929 31.6 4725 69744 966 24.5
Powell River 1996 1610 30672 570 31.7 60 31444 676 29.7 1545 30641 566 31.9
Powell River 2001 1725 33761 566 29 160 38824 677 32.1 1565 33240 555 28.6
Powell River 2006 1660 35604.7 590.4 29.8 150 32165.8 555.2 33.8 1510 35942 592 29.5
Powell River 2011 1770 40760 706 32.2 170 43111 771 42.2 1600 40510 699 31.1
Skeena - Queen Charlotte 1996 2900 41393 574 24.3 1000 33893 592 30.9 1895 45336 565 20.8
Skeena - Queen Charlotte 2001 2465 40774 587 26.6 990 30045 585 32.9 1475 47991 589 22.3
Skeena - Queen Charlotte 2006 2350 39785.1 563.8 24.7 1205 33980.6 557 26.6 1150 45877.2 571.1 22.7
Skeena - Queen Charlotte 2011 2155 48267 685 26 1135 40393 677 28.7 1025 56994 694 23.2
Squamish - Lillooet 1996 3425 42327 801 29.8 220 31342 680 34.8 3200 43091 808 29.5
Squamish - Lillooet 2001 3660 51568 930 28.1 220 42316 677 26.8 3435 52164 948 28.2
Squamish - Lillooet 2006 3650 55191.8 1020.8 28.1 290 46562.3 866.1 27.9 3360 55936.5 1034.4 28.2
Squamish - Lillooet 2011 3595 59765 1170 32.4 300 57303 994 32.7 3290 59991 1187 32.4
Stikine 1996 185 59018 516 13.8 45 40835 446 20.3 140 64922 540 11.6
Stikine 2001 110 51860 499 25.4 15 0 0 0 95 59472 537 16.7
Stikine 2006 105 81641.1 691.4 13.7 15 33948 561.3 19 90 91051.7 717.5 12.3
Stikine 2011 80 79617 1070 17.6 35 116457 1758 14 55 57121 546 18.4
Strathcona 2011 3950 45729 801 31.4 715 48816 820 31 3235 45050 797 31.4
Sunshine Coast 1996 2190 33774 616 31.7 130 30153 637 35.7 2055 34008 613 31.4
Sunshine Coast 2001 2165 35403 677 34 140 34976 728 36.9 2025 35433 673 33.8
Sunshine Coast 2006 2110 41507.7 777.9 31 210 41049.1 921.2 32.2 1900 41558.8 764.3 30.8
Sunshine Coast 2011 2055 53805 986 30.5 150 60034 1104 34.4 1905 53311 977 30.3
Thompson - Nicola 1996 10675 31841 624 33.1 1180 27005 615 38.4 9495 32441 626 32.5
Thompson - Nicola 2001 10875 34347 629 31.4 1610 34239 637 32.8 9265 34366 627 31.2
Thompson - Nicola 2006 10575 37168.1 693.7 31.7 1675 34112 663 33 8900 37743.3 699.5 31.5
Thompson - Nicola 2011 11060 46135 833 30.3 1770 40574 860 35.1 9285 47196 827 29.4
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Average Annual Incomes by Regional District in BC</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<style type="text/css">
svg{background-color: #818785;}
rect:hover {
fill: #2BCC14;
}
.axis path,
.axis line {
fill: none;
stroke: black;
shape-rendering; crispEdges;
}
.axis text {
font-family: sans-serif;
font-size: 11px;
}
.y.axis path,
.y.axis line {
opacity: 0;
}
</style>
</head>
<body>
<h1>Average Incomes in British Columbia</h1>
<p>Average Annual Incomes by Regional District in BC</p>
<script type="text/javascript">
var w = 900;
var h = 3200;
var padding = [20, 20, 30, 210]; //top, right, bottom, left
var widthScale = d3.scale.linear()
.range([ 0, w - padding[1] -
padding[3] ]);
var heightScale = d3.scale.ordinal()
.rangeRoundBands([ padding[0], h - padding[2] ], 0.1);
var xAxis = d3.svg.axis()
.scale(widthScale)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(heightScale)
.orient("left");
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
d3.csv("Core_Housing_Need_data.csv", function(data) {
data.sort(function(a, b) {
return d3.descending(+a.Total_all_Average_Household_Income, +b.Total_all_Average_Household_Income);
});
widthScale.domain([ 0, d3.max(data, function(d) {
return +d.Total_all_Average_Household_Income;
}) ]);
heightScale.domain(data.map(function(d) { return d.Geography; } ));
var rects = svg.selectAll("rect")
.data(data)
.enter()
.append("rect")
rects.attr("x", 0)
.attr("y", function(d, i) {
return heightScale(d.Geography);
})
.attr("width", function(d) {
return widthScale(d.Total_all_Average_Household_Income);
})
.attr("height", heightScale.rangeBand())
.attr("fill", "#9DFEFF")
.append("title")
.text(function(d) {
return d.Geography + "'s average household income in " + d.Year + " was $" + d.Total_all_Average_Household_Income;
});
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(" + padding[3] + "," + (h - padding[2]) + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.attr("transform", "translate(" + padding[3] + ",0)")
.call(yAxis);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment