Skip to content

Instantly share code, notes, and snippets.

@gelicia
Created November 24, 2013 16:37
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 gelicia/7629114 to your computer and use it in GitHub Desktop.
Save gelicia/7629114 to your computer and use it in GitHub Desktop.
county school plans mn
{"description":"county school plans mn","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/EBvlaKz.png"}
countyName metro pop-1998 pop-2001 pop-2004 pop-2007 pop-2010 collOrByond-1998 collOrByond-2001 collOrByond-2004 collOrByond-2007 collOrByond-2010
Aitkin County 175 363 376 376 364 82.00951312 76.37848464 81.89915023 82.29072907 83.91085272
Anoka County MinneapolisStPaulBloomingtonMNWI 9162 10185 10276 10786 10064 79.5326354 83.91926229 85.24913342 86.83953495 90.35528545
Becker County 920 936 864 808 660 74.1364318 81.64380197 81.80558526 83.31313993 89.59549802
Beltrami County 1131 1151 1028 826 1004 76.35980432 78.27400921 78.59493097 82.760181 83.08695652
Benton County StCloudMN 1087 1061 984 1078 1083 72.73878177 76.81163699 81.88165959 82.30557738 87.76533019
Big Stone County 97 119 203 164 176 75.85526316 81.67325428 79.08916066 83.66554054 82.94871795
Blue Earth County MankatoNorthMankatoMN 1921 1570 1700 1533 1758 78.9771352 83.2223097 82.66465669 85.56413557 89.6675679
Brown County 1028 805 789 408 577 71.62432861 77.05870562 80.4721036 86.96679665 86.54188949
Carlton County DuluthMNWI 1223 826 994 1128 1101 79.01286539 82.86728666 86.70677046 86.71241201 88.80343767
Carver County MinneapolisStPaulBloomingtonMNWI 1596 1700 2371 2486 2717 80.17691061 83.44607385 85.89817725 87.63388775 91.15177018
Cass County 736 407 569 728 594 73.23717631 81.54522694 77.16044439 81.79089027 84.79143647
Chippewa County 333 461 189 501 172 78.07287595 81.19637794 84.82361266 84.77287582 88.76201923
Chisago County MinneapolisStPaulBloomingtonMNWI 1261 1390 14 1411 1481 74.76557621 79.18690598 82.66098485 85.37363624
Clay County FargoNDMN 1528 1541 1617 1535 1084 81.03755166 85.12980837 88.27506818 88.09329266 88.30798931
Clearwater County 344 305 14 267 258 67.81935326 75.7797449 82.7991453 77.73809524
Cook County 125 115 127 132 127 83.22943723 85.03367004 83.43209877 83.82352942 81.06187291
Cottonwood County 387 368 518 486 310 76.91784711 82.61370458 83.82543944 85.52675308 87.26328944
Crow Wing County 1765 1726 1676 1572 1223 78.14574993 83.00243764 84.64501004 82.6938499 89.53477043
Dakota County MinneapolisStPaulBloomingtonMNWI 10586 11618 12611 13065 12815 84.09647029 87.66367217 86.91195868 89.33718784 91.3789362
Dodge County RochesterMN 764 736 648 734 707 79.45115578 79.02461388 84.57347609 80.55152395 84.04205711
Douglas County 861 979 925 846 846 79.8023398 81.84549965 88.01215281 89.82758621 90.25821762
Faribault County 578 486 491 431 135 75.36851785 79.42826812 82.15132336 80.72878093 77.69607843
Fillmore County RochesterMN 697 548 422 474 430 79.56197142 79.68595522 83.70021044 80.19957984 84.30058158
Freeborn County 984 892 902 842 639 77.56533889 81.91875004 83.73943081 81.38086404 88.06681956
Goodhue County 1594 1116 1294 1234 963 77.50616372 83.18450565 81.88843057 86.18115341 87.02135774
Grant County 183 280 203 186 144 78.42576711 82.54830355 85.65464829 85.53100499 90.37037038
Hennepin County MinneapolisStPaulBloomingtonMNWI 22070 22411 23007 23972 23937 86.23790333 88.25485043 89.39376289 90.13028115 92.27509673
Houston County LaCrosseOnalaskaWIMN 483 682 661 581 554 76.00975608 84.06574253 82.31456569 85.84392932 90.02389487
Hubbard County 465 430 500 475 400 69.53343932 82.43122474 76.58765877 79.60384436 83.57592094
Isanti County MinneapolisStPaulBloomingtonMNWI 1103 961 1057 999 851 74.37087648 76.30892659 76.86803232 81.09376421 88.07769837
Itasca County 1196 1195 963 918 1183 80.42992807 85.90740214 86.12558025 87.71545668 88.74228401
Jackson County 274 367 342 272 252 80.18223288 84.57809857 88.15649882 83.57563605 87.16856061
Kanabec County 541 507 372 493 440 74.00839445 75.20336626 77.1168379 77.3149927 83.35443038
Kandiyohi County 1143 897 989 929 814 85.85667507 85.63700295 87.56325604 88.20078762 87.61019976
Kittson County 142 226 167 163 151 75.89262187 85.65669764 85.66172826 87.75143679 82.63988523
Koochiching County 462 411 341 227 252 77.3396797 80.23015873 77.81358924 81.59663866 84.56881034
Lac Qui Parle County 413 372 387 334 277 80.3402247 82.76176369 82.45114799 87.28632479 85.88527552
Lake County 343 363 341 230 183 79.32332016 79.83549172 80.65829709 80.85032599 87.3995984
Lake of the Woods County 170 169 167 136 108 73.48066192 83.51052902 84.90847169 82.22222222 82.92682927
Le Sueur County MinneapolisStPaulBloomingtonMNWI 946 644 807 768 673 70.39222308 76.29133081 79.94235902 78.82823948 83.52678572
Lincoln County 282 162 198 224 159 70.39439597 74.64932047 76.11111111 76.07317073 81.11790879
Lyon County 1018 903 898 854 751 74.51006383 80.17571424 84.12193447 85.86761781 85.34049473
McLeod County 1239 1019 1100 1056 659 74.41212254 83.0220086 83.38175303 86.8130227 91.18796564
Mahnomen County 0 201 130 205 177 71.19956064 67.67506143 76.5 81.82234432
Marshall County 377 197 280 270 283 82.09767289 87.27257675 88.91079726 85.81535444 88.19444445
Martin County 885 743 495 618 503 76.26002163 79.27476495 85.33817811 85.01887147 86.27873563
Meeker County 1196 1120 1176 1082 1072 77.12171535 79.48749043 79.83871735 83.55013008 87.44768501
Mille Lacs County MinneapolisStPaulBloomingtonMNWI 1133 994 1204 1132 1112 73.59471175 81.74210808 77.56224284 80.01404495 84.74929578
Morrison County 1156 1129 497 1024 1031 71.71801367 73.28263058 74.06030512 83.12855931 84.2501616
Mower County 764 855 1025 1005 1056 76.4598101 78.81419034 84.9140717 88.84729295 90.04065041
Murray County 352 319 294 161 124 82.78836132 85.25054275 88.5226263 94.72811671 91.38342278
Nicollet County MankatoNorthMankatoMN 468 415 435 434 292 78.95541787 81.02453102 85.50343965 80.25764558 86.10780142
Nobles County 660 663 687 650 608 78.59061758 81.635175 82.40973693 83.24027819 86.36431007
Norman County 264 258 252 235 221 75.85794229 80.38127561 84.21274456 85.70906433 83.1981982
Olmsted County RochesterMN 3296 3661 2931 3844 3291 84.48983118 87.06115583 89.44200574 87.9844301 90.40211896
Otter Tail County 1216 1111 1401 1488 1049 74.008243 78.16616069 81.28516806 85.03710663 86.63492064
Pennington County 405 356 444 438 374 79.19241976 84.41872085 87.60868919 88.26065892 89.33687003
Pine County 817 806 745 571 719 73.42609101 75.77096619 77.17373615 82.98796791 83.15882732
Pipestone County 363 332 314 321 224 78.29627859 80.12536542 79.50965332 83.26210827 88.35943468
Polk County GrandForksNDMN 1105 1072 766 811 948 81.51332045 82.31186672 83.8431371 86.04983661 84.43305446
Pope County 371 392 337 247 223 79.43508985 81.88809414 85.83056976 88.55606759 88.63798009
Ramsey County MinneapolisStPaulBloomingtonMNWI 12244 12382 12546 11766 11572 82.45641391 85.39530962 87.36771185 88.31706962 89.67259152
Red Lake County 220 172 154 144 132 81.89357253 85.3422619 80.98565091 79.8992674 85.13862025
Redwood County 513 661 434 414 385 74.88351981 79.34202256 83.58458421 84.35621726 85.78276949
Renville County 571 498 350 303 349 80.73991952 83.77160208 88.41479701 85.16791045 88.12541146
Rice County 1479 1357 1180 1425 1329 79.20523809 83.20865549 84.98027703 87.35515259 88.37349398
Rock County 281 256 251 216 234 74.84060881 83.25916508 79.80321794 81.02088662 84.33913366
Roseau County 758 758 709 675 631 79.53764722 84.09463229 85.4869623 84.88142293 84.82677453
St. Louis County DuluthMNWI 4844 5147 4217 4161 4077 81.60247362 85.00495685 87.78942045 87.99790116 89.2447654
Scott County MinneapolisStPaulBloomingtonMNWI 1931 2051 2672 2839 3753 78.77770889 81.90318419 83.32280649 86.50437401 88.12108262
Sherburne County MinneapolisStPaulBloomingtonMNWI 1706 2254 2566 2986 3273 76.45475875 79.72474199 84.23089038 85.92536689 89.89886008
Sibley County MinneapolisStPaulBloomingtonMNWI 517 502 483 416 381 72.3215259 80.26602535 79.72456249 86.91810345 82.15945219
Stearns County StCloudMN 5090 4441 3824 3958 2824 76.5066023 80.56291457 82.38685108 84.30309916 85.35471318
Steele County 1052 1219 1222 1232 1140 80.09909339 84.13752804 83.90489642 88.90558599
Stevens County 17 240 241 218 197 82.05636956 83.44827586 82.23684211 93.4375
Swift County 351 314 148 312 289 77.90102568 85.10964912 78.12587412 82.47787611 80.15482055
Todd County 815 902 813 772 697 73.22743942 79.00157792 79.86794718 82.64063553 87.45283019
Traverse County 138 142 124 118 105 79.69971001 86.43127083 86.95736434 87.5331565 84.3495935
Wabasha County RochesterMN 842 847 863 902 893 73.07056741 78.39528828 83.04629112 79.08644204 87.33197653
Wadena County 534 592 606 537 450 73.84761784 76.31441475 79.24333602 82.40104841 84.85915493
Waseca County 869 775 570 597 441 75.78425369 81.02882058 82.10635383 83.20824018 87.60991207
Washington County MinneapolisStPaulBloomingtonMNWI 5944 5607 6068 6703 6551 84.74147364 86.56979646 88.0820784 89.79356647 93.03266986
Watonwan County 475 390 421 378 363 76.05530623 77.42362021 81.80489101 79.78014185 79.1005291
Wilkin County 297 290 296 262 215 81.9108964 84.73307699 82.61982571 89.38106796 88.54800937
Winona County 1190 1192 539 1130 1014 76.80908882 80.06410601 84.12286072 81.39952154 83.97121862
Wright County MinneapolisStPaulBloomingtonMNWI 3240 2175 2656 2518 2916 74.83426759 81.80711009 82.84211315 84.66636564 88.12257
Yellow Medicine County 296 438 394 363 314 77.84503007 80.04408008 81.43263646 81.4764268 88.69479734
Statewide 134398 133629 131862 136549 130908 77.46302031 81.40991749 82.96220242 84.32527772 86.58190305
var data = tributary.data;
function countyObj(countyInfo){
var outArr = [];
var popArr = [];
var collArr = [];
for(var prop in countyInfo){
if (typeof countyInfo[prop] === 'string'){
if (prop == 'countyName'){
outArr.countyName = countyInfo[prop];
}
else if (prop == 'metro'){
outArr.metro = countyInfo[prop];
}
else if (prop.substring(0,3) == 'pop'){
popArr[prop.substring(4)] = Number(countyInfo[prop]);
}
else if (prop.substring(0,11) == 'collOrByond'){
collArr[prop.substring(12)] = (Number(countyInfo[prop]) / 100) * popArr[prop.substring(12)];
}
}
}
outArr.populations = popArr;
outArr.collegeAmt = collArr;
return outArr;
}
var parseDate = d3.time.format("%Y");
var years = ["1998","2001","2004","2007","2010"];
years = years.map(function(d){return parseDate.parse(d);});
var countyIdx = 79;
var margin = {top: 20, right: 20, bottom: 30, left: 78},
width = 348 - margin.left - margin.right,
height = 204 - margin.top - margin.bottom;
var countyData = countyObj(data[countyIdx]);
var x = d3.time.scale()
.range([0, width])
.domain(d3.extent(years));
var y = d3.scale.linear()
.range([height, 0])
.domain([0, d3.max(countyData.populations, function(d,i) {return d; })]);
var xAxis = d3.svg.axis()
.scale(x)
.tickValues(years)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
var popArea = d3.svg.area()
.x(function(d,i) { return x(years[i]); })
.y0(height)
.y1(function(d) {return y(countyData.populations[d.getFullYear()]); });
var schoolArea = d3.svg.area()
.x(function(d,i) { return x(years[i]); })
.y0(height)
.y1(function(d) { return y(countyData.collegeAmt[d.getFullYear()]); });
var stateAvgLine = d3.svg.line()
.x(function(d,i) { return x(years[i]); })
.y(function(d) {
var population = countyData.populations[d.getFullYear()];
var stateInfo = data[data.length-1];
return y((stateInfo['collOrByond-'+d.getFullYear()]/100) * population);
});
var svg = d3.select("svg")
// .attr("width", width + margin.left + margin.right)
// .attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("path")
.datum(years)
.attr("class", "popArea")
.attr("d", popArea);
svg.append("path")
.datum(years)
.attr("class", "schoolArea")
.attr("d", schoolArea);
svg.append("path")
.datum(years)
.attr("class", "stateLine")
.attr("d", stateAvgLine);
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis);
var index = svg.append("g")
.attr("transform", "translate(0," + 179 + ")");
index.append("rect")
.attr({
height: 20,
width: 20,
'class': 'popArea'
})
index.append("rect")
.attr({
y: 25,
height: 20,
width: 20,
'class': 'schoolArea'
});
index.append("path")
.attr({
d : "M0,50L22,50",
"transform": "translate(0," + 11 + ")",
'class': 'stateLine'
})
index.append("text").attr({
x: 25,
y: 16
}).text("Students Surveyed")
index.append("text").attr({
x: 25,
y: 41
}).text("Students Planning on Going to College or Beyond")
index.append("text").attr({
x: 25,
y: 66
}).text("State Avg % of Students Planning on Going to College or Beyond")
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
text{
font-size:12px
}
.popArea {
fill: #007AFF;
}
.schoolArea {
fill: #1750CA;
}
.stateLine {
fill: none;
stroke: #FFFF00;
stroke-width: 3;
stroke-dasharray: 5,5;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment