[ Launch: Maps: Choropleth ] afc3025d053dc6819486 by poezn
[ Launch: Choropleth Test ] 08e7b610d21e4d8357a6 by poezn
[ Launch: Choropleth Test ] 7494487 by poezn
-
-
Save poezn/afc3025d053dc6819486 to your computer and use it in GitHub Desktop.
Maps: Rects
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
{"description":"Maps: Rects","endpoint":"","display":"svg","public":true,"require":[{"name":"TopoJSON","url":"http://d3js.org/topojson.v1.min.js"}],"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},"us.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"styles.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"grid.tsv":{"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/norn4MH.png","ajax-caching":true,"inline-console":true} |
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
fipst | stab | state | avgshare | avgshare94_00 | avgshare01_07 | avgshare08_12 | |
---|---|---|---|---|---|---|---|
37 | NC | North Carolina | 3.56 | 2.53 | 4.56 | 2.64 | |
1 | AL | Alabama | 3.22 | 3.55 | 2.95 | 2.58 | |
28 | MS | Mississippi | 2.94 | 3.77 | 2.99 | 1.71 | |
5 | AR | Arkansas | 2.89 | 1.91 | 3.27 | 3.16 | |
47 | TN | Tennessee | 2.86 | 2.64 | 2.77 | 2.85 | |
45 | SC | South Carolina | 2.61 | 1.6 | 3.57 | 2.14 | |
23 | ME | Maine | 2.58 | 2.59 | 2.61 | 2.31 | |
26 | MI | Michigan | 2.55 | 0.8 | 2.2 | 4.62 | |
41 | OR | Oregon | 2.38 | 1.39 | 2.37 | 3.03 | |
21 | KY | Kentucky | 2.24 | 2.06 | 2.19 | 2.38 | |
18 | IN | Indiana | 2.07 | 0.97 | 2.3 | 2.67 | |
2 | AK | Alaska | 1.88 | 2.52 | 2.6 | 0 | |
42 | PA | Pennsylvania | 1.79 | 1.53 | 2.07 | 1.62 | |
55 | WI | Wisconsin | 1.73 | 1.03 | 1.8 | 2.27 | |
39 | OH | Ohio | 1.72 | 0.77 | 1.84 | 2.46 | |
53 | WA | Washington | 1.69 | 1.04 | 2.44 | 1.32 | |
44 | RI | Rhode Island | 1.64 | 1.87 | 1.5 | 1.57 | |
13 | GA | Georgia | 1.51 | 1.76 | 1.65 | 0.96 | |
16 | ID | Idaho | 1.51 | 1.23 | 1.9 | 1.22 | |
54 | WV | West Virginia | 1.45 | 1.23 | 1.38 | 1.85 | |
51 | VA | Virginia | 1.38 | 0.98 | 1.66 | 1.28 | |
40 | OK | Oklahoma | 1.3 | 1.18 | 1.96 | 0.88 | |
20 | KS | Kansas | 1.27 | 0.86 | 1.42 | 1.35 | |
35 | NM | New Mexico | 1.26 | 1.76 | 0.4 | 1.69 | |
29 | MO | Missouri | 1.25 | 1.06 | 1.28 | 1.48 | |
33 | NH | New Hampshire | 1.25 | 0.67 | 1.76 | 0.96 | |
50 | VT | Vermont | 1.14 | 0.35 | 1.84 | 1.14 | |
25 | MA | Massachusetts | 1.07 | 0.89 | 1.09 | 1.28 | |
17 | IL | Illinois | 1.06 | 0.55 | 1.36 | 1.19 | |
48 | TX | Texas | 1.05 | 1.17 | 0.97 | 0.91 | |
27 | MN | Minnesota | 0.99 | 0.39 | 1.18 | 1.3 | |
9 | CT | Connecticut | 0.97 | 0.5 | 0.97 | 1.36 | |
30 | MT | Montana | 0.91 | 1.78 | 0.78 | 0.75 | |
19 | IA | Iowa | 0.89 | 0.33 | 1.04 | 1.21 | |
46 | SD | South Dakota | 0.86 | 0.16 | 1 | 1.3 | |
22 | LA | Louisiana | 0.85 | 1.07 | 0.5 | 0.98 | |
34 | NJ | New Jersey | 0.85 | 1.18 | 0.8 | 0.73 | |
4 | AZ | Arizona | 0.83 | 0.59 | 0.68 | 1.13 | |
56 | WY | Wyoming | 0.82 | 2.44 | 0.21 | 0.04 | |
36 | NY | New York | 0.82 | 0.94 | 0.76 | 0.91 | |
49 | UT | Utah | 0.74 | 0.76 | 0.62 | 0.95 | |
8 | CO | Colorado | 0.74 | 0.87 | 0.67 | 0.75 | |
6 | CA | California | 0.72 | 0.47 | 0.75 | 0.86 | |
31 | NE | Nebraska | 0.62 | 0.34 | 0.75 | 0.62 | |
38 | ND | North Dakota | 0.6 | 1.16 | 0.16 | 0.75 | |
10 | DE | Delaware | 0.53 | 0.14 | 0.43 | 1.09 | |
24 | MD | Maryland | 0.47 | 0.54 | 0.5 | 0.46 | |
12 | FL | Florida | 0.3 | 0.24 | 0.28 | 0.39 | |
32 | NV | Nevada | 0.26 | 0.34 | 0.2 | 0.21 | |
15 | HI | Hawaii | 0.06 | 0.1 | 0.14 | 0.03 | |
11 | DC | District of Columbia | 0.01 | 0.03 | 0 | 0.02 |
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
stab | col | row | |
---|---|---|---|
ME | 11 | 0 | |
WI | 6 | 1 | |
VT | 10 | 1 | |
NH | 11 | 1 | |
WA | 1 | 2 | |
ID | 2 | 2 | |
MT | 3 | 2 | |
ND | 4 | 2 | |
MN | 5 | 2 | |
IL | 6 | 2 | |
MI | 7 | 2 | |
NY | 9 | 2 | |
MA | 10 | 2 | |
OR | 1 | 3 | |
NV | 2 | 3 | |
WY | 3 | 3 | |
SD | 4 | 3 | |
IA | 5 | 3 | |
IN | 6 | 3 | |
OH | 7 | 3 | |
PA | 8 | 3 | |
NJ | 9 | 3 | |
CT | 10 | 3 | |
RI | 11 | 3 | |
CA | 1 | 4 | |
UT | 2 | 4 | |
CO | 3 | 4 | |
NE | 4 | 4 | |
MO | 5 | 4 | |
KY | 6 | 4 | |
WV | 7 | 4 | |
VA | 8 | 4 | |
MD | 9 | 4 | |
DE | 10 | 4 | |
AZ | 2 | 5 | |
NM | 3 | 5 | |
KS | 4 | 5 | |
AR | 5 | 5 | |
TN | 6 | 5 | |
NC | 7 | 5 | |
SC | 8 | 5 | |
DC | 9 | 5 | |
OK | 4 | 6 | |
LA | 5 | 6 | |
MS | 6 | 6 | |
AL | 7 | 6 | |
GA | 8 | 6 | |
HI | 0 | 7 | |
AK | 1 | 7 | |
TX | 4 | 7 | |
FL | 9 | 7 |
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 dataValues = tb.data; | |
var dataGrid = tb.grid; | |
var values = {}, | |
lookup = {}; | |
var w = 63, | |
padding = w/15; | |
var columnMetric = "avgshare08_12", | |
columnStateName = "state"; | |
columnStateNameShort = "stab"; | |
_.each(dataValues, function(d) { | |
values[d[columnStateNameShort]] = { | |
"value": +d[columnMetric], | |
"id": d[columnStateNameShort], | |
"label": d[columnStateName] | |
} | |
}); | |
_.each(dataGrid, function(d) { | |
values[d[columnStateNameShort]]["grid"] = { | |
"row": +d.row, | |
"col": +d.col | |
}; | |
lookup[d[columnStateNameShort]] = d[columnStateName]; | |
}); | |
var max = d3.max(_.chain(values).values().pluck("value").value()); | |
// max = 15; | |
console.log(max); | |
var width = 960, | |
height = 500; | |
var quantize = d3.scale.quantize() | |
.domain([0, max]) | |
.range(d3.range(4).map(function(i) { return "q" + i + "-4"; })); | |
var svg = g; | |
function ready() { | |
var states = svg.selectAll("g") | |
.data(_.values(values)) | |
.enter().append("g") | |
.attr({ | |
"class": function(d) { return "state " + quantize(d.value); }, | |
"transform": function(d) { | |
var tx = d.grid.col * (w + padding), | |
ty = d.grid.row * (w + padding); | |
return "translate(" + [tx, ty].join(" ") + ")" | |
} | |
}); | |
states.append("rect") | |
.attr({ | |
"width": w, | |
"height": w, | |
"rx": w/3 | |
}); | |
states.append("text") | |
.attr({ | |
"text-anchor": "middle", | |
"x": w/2, | |
"y": w/2 + 5 | |
}) | |
.text(function(d) { return d["id"] }) | |
} | |
ready(); |
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
.counties { | |
fill: none; | |
} | |
.state { | |
stroke-linejoin: round; | |
font-size: 14px | |
} | |
#display { | |
background-color: #FFFFFF; | |
} | |
.q0-4 text { fill: #001966; } | |
.q1-4 text { fill: #001966; } | |
.q2-4 text { fill: #001966; } | |
.q3-4 text { fill: #d8e9f7; } | |
.q0-4 rect { fill: #eff3ff; } | |
.q1-4 rect { fill: #bdd7e7; } | |
.q2-4 rect { fill: #6baed6; } | |
.q3-4 rect { fill: #2171b5; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment