Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mgerring/datafest-moneymap
Browse files Browse the repository at this point in the history
  • Loading branch information
postphotos committed Feb 3, 2013
2 parents b2bff88 + 81454a0 commit e31d44f
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 11 deletions.
64 changes: 62 additions & 2 deletions public/css/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ header {
top:81px;
right:10px;
width:200px;
height:125px;
height:325px;
background:rgba(255,255,255,0.8);
box-shadow:0 0 5px rgba(0,0,0,.5);
border-radius:5px;
Expand Down Expand Up @@ -91,6 +91,29 @@ footer {
height:20px;
background:white;
}
.inner {
height:0;
text-align:center;
}
a.lister, a.locationer{
background: url('../img/sprites.png') no-repeat;
position:relative;
display:inline-block;
text-indent:101%;
margin-right:10px;
}

a.lister{
background-position: -76px 0;
width: 65px;
height: 65px;
}

a.locationer{
background-position: 0 0;
width: 65px;
height: 65px;
}
}

body.footer-up {
Expand All @@ -104,6 +127,7 @@ body.footer-up {
.inner {
bottom:0;
height:120px;
padding-top:10px;
}
}
}
Expand All @@ -112,11 +136,47 @@ body.footer-up {
left:30%;
}



path {
fill: #000;
fill-opacity: .2;
fill-opacity: .8;
stroke: #fff;
stroke-width: 1.5px;
.apathy( @num ) {
fill: lighten(#b63b3d,percentage(@num));
}

&.apathy-1{
.apathy(0);
}
&.apathy-2{
.apathy(.05);
}
&.apathy-3{
.apathy(.10);
}
&.apathy-4{
.apathy(.15);
}
&.apathy-5{
.apathy(.20);
}
&.apathy-6{
.apathy(.25);
}
&.apathy-7{
.apathy(.30);
}
&.apathy-8{
.apathy(.35);
}
&.apathy-9{
.apathy(.40);
}
&.apathy-10{
.apathy(.45);
}
}

path:hover {
Expand Down
2 changes: 1 addition & 1 deletion public/data/ca/data-l.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/data/ca/data-u.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"totalmoneyspentnorm": "82.35812", "moneypereligiblevoter": "2.468711", "district": "1", "nocontributionsnorm": "96.49426", "votesperregisterednorm": "100", "votespereligiblenorm": "77.19106", "votesperregistered": ".74878", "moneypereligiblevoternorm": "64.65088", "votespereligible": ".6143688", "totalmoneyspent": "1661028", "nocontributions": "1800"}, {"totalmoneyspentnorm": "6.16484", "moneypereligiblevoter": ".4093141", "district": "3", "nocontributionsnorm": "11.14943", "votesperregisterednorm": "87.63936", "votespereligiblenorm": "55.56696", "votesperregistered": ".7213966", "moneypereligiblevoternorm": "4.121686", "votespereligible": ".5756653", "totalmoneyspent": "250594", "nocontributions": "315"}, {"totalmoneyspentnorm": "100", "moneypereligiblevoter": "3.671401", "district": "5", "nocontributionsnorm": "100", "votesperregisterednorm": "66.71287", "votespereligiblenorm": "24.89182", "votesperregistered": ".6750365", "moneypereligiblevoternorm": "100", "votespereligible": ".520762", "totalmoneyspent": "1987601", "nocontributions": "1861"}, {"totalmoneyspentnorm": "16.90817", "moneypereligiblevoter": ".7899084", "district": "7", "nocontributionsnorm": "22.18391", "votesperregisterednorm": "91.67287", "votespereligiblenorm": "100", "votesperregistered": ".7303323", "moneypereligiblevoternorm": "15.30801", "votespereligible": ".655193", "totalmoneyspent": "449466.6", "nocontributions": "507"}, {"totalmoneyspentnorm": "19.03839", "moneypereligiblevoter": ".8215308", "district": "9", "nocontributionsnorm": "38.21839", "votesperregisterednorm": "66.79771", "votespereligiblenorm": "63.45133", "votesperregistered": ".6752245", "moneypereligiblevoternorm": "16.23744", "votespereligible": ".589777", "totalmoneyspent": "488899.5", "nocontributions": "786"}, {"totalmoneyspentnorm": "24.0489", "moneypereligiblevoter": ".8763332", "district": "11", "nocontributionsnorm": "35.45977", "votesperregisterednorm": "55.68352", "votespereligiblenorm": "35.39851", "votesperregistered": ".6506024", "moneypereligiblevoternorm": "17.84818", "votespereligible": ".5395672", "totalmoneyspent": "581650.4", "nocontributions": "738"}, {"totalmoneyspentnorm": "45.43339", "moneypereligiblevoter": "1.767386", "district": "13", "nocontributionsnorm": "69.54023", "votesperregisterednorm": "78.13975", "votespereligiblenorm": "68.40397", "votesperregistered": ".7003514", "moneypereligiblevoternorm": "44.03775", "votespereligible": ".5986414", "totalmoneyspent": "977504.2", "nocontributions": "1331"}, {"totalmoneyspentnorm": "19.27474", "moneypereligiblevoter": ".9147846", "district": "15", "nocontributionsnorm": "28.50575", "votesperregisterednorm": "56.48561", "votespereligiblenorm": "26.95181", "votesperregistered": ".6523793", "moneypereligiblevoternorm": "18.97833", "votespereligible": ".524449", "totalmoneyspent": "493274.8", "nocontributions": "617"}, {"totalmoneyspentnorm": "36.02762", "moneypereligiblevoter": "1.30619", "district": "17", "nocontributionsnorm": "56.55172", "votesperregisterednorm": "92.94174", "votespereligiblenorm": "72.80564", "votesperregistered": ".7331433", "moneypereligiblevoternorm": "30.4824", "votespereligible": ".6065196", "totalmoneyspent": "803391.6", "nocontributions": "1105"}, {"totalmoneyspentnorm": "80.7351", "moneypereligiblevoter": "3.041245", "district": "19", "nocontributionsnorm": "99.02299", "votesperregisterednorm": "93.98001", "votespereligiblenorm": "72.1074", "votesperregistered": ".7354435", "moneypereligiblevoternorm": "81.47865", "votespereligible": ".6052699", "totalmoneyspent": "1630983", "nocontributions": "1844"}, {"totalmoneyspentnorm": "0", "moneypereligiblevoter": ".2690811", "district": "21", "nocontributionsnorm": "0", "votesperregisterednorm": "49.11674", "votespereligiblenorm": "27.16907", "votesperregistered": ".6360545", "moneypereligiblevoternorm": "0", "votespereligible": ".5248379", "totalmoneyspent": "136475", "nocontributions": "121"}, {"totalmoneyspentnorm": "18.5258", "moneypereligiblevoter": ".8506544", "district": "23", "nocontributionsnorm": "18.10345", "votesperregisterednorm": "52.44405", "votespereligiblenorm": "14.05868", "votesperregistered": ".6434258", "moneypereligiblevoternorm": "17.09343", "votespereligible": ".5013725", "totalmoneyspent": "479410.9", "nocontributions": "436"}, {"totalmoneyspentnorm": "16.23976", "moneypereligiblevoter": ".6988137", "district": "25", "nocontributionsnorm": "12.58621", "votesperregisterednorm": "57.72372", "votespereligiblenorm": "47.26991", "votesperregistered": ".6551222", "moneypereligiblevoternorm": "12.63058", "votespereligible": ".560815", "totalmoneyspent": "437093.3", "nocontributions": "340"}, {"totalmoneyspentnorm": "48.07119", "moneypereligiblevoter": "1.745744", "district": "27", "nocontributionsnorm": "56.14943", "votesperregisterednorm": "72.13197", "votespereligiblenorm": "84.79749", "votesperregistered": ".6870419", "moneypereligiblevoternorm": "43.40165", "votespereligible": ".627983", "totalmoneyspent": "1026333", "nocontributions": "1098"}, {"totalmoneyspentnorm": "33.98375", "moneypereligiblevoter": "1.437288", "district": "29", "nocontributionsnorm": "37.41379", "votesperregisterednorm": "33.82348", "votespereligiblenorm": "40.3757", "votesperregistered": ".6021742", "moneypereligiblevoternorm": "34.33559", "votespereligible": ".5484755", "totalmoneyspent": "765556.9", "nocontributions": "772"}, {"totalmoneyspentnorm": "22.54585", "moneypereligiblevoter": "1.162735", "district": "31", "nocontributionsnorm": "15.86207", "votesperregisterednorm": "37.36461", "votespereligiblenorm": "18.03661", "votesperregistered": ".6100191", "moneypereligiblevoternorm": "26.26603", "votespereligible": ".5084923", "totalmoneyspent": "553827.1", "nocontributions": "397"}, {"totalmoneyspentnorm": "18.20961", "moneypereligiblevoter": "1.142543", "district": "33", "nocontributionsnorm": "10.57471", "votesperregisterednorm": "0", "votespereligiblenorm": "0", "votesperregistered": ".5272425", "moneypereligiblevoternorm": "25.67254", "votespereligible": ".4762098", "totalmoneyspent": "473557.9", "nocontributions": "305"}, {"totalmoneyspentnorm": "16.70843", "moneypereligiblevoter": ".9259291", "district": "35", "nocontributionsnorm": "12.87356", "votesperregisterednorm": "22.84129", "votespereligiblenorm": "25.87839", "votesperregistered": ".5778446", "moneypereligiblevoternorm": "19.30589", "votespereligible": ".5225278", "totalmoneyspent": "445769.1", "nocontributions": "345"}, {"totalmoneyspentnorm": "26.57476", "moneypereligiblevoter": "1.025094", "district": "37", "nocontributionsnorm": "28.90805", "votesperregisterednorm": "51.79779", "votespereligiblenorm": "74.50986", "votesperregistered": ".6419941", "moneypereligiblevoternorm": "22.22051", "votespereligible": ".6095699", "totalmoneyspent": "628407.2", "nocontributions": "624"}, {"totalmoneyspentnorm": "28.57493", "moneypereligiblevoter": ".9708326", "district": "39", "nocontributionsnorm": "19.08046", "votesperregisterednorm": "82.00311", "votespereligiblenorm": "42.31423", "votesperregistered": ".7089102", "moneypereligiblevoternorm": "20.62568", "votespereligible": ".5519451", "totalmoneyspent": "665432.9", "nocontributions": "453"}]
{"1":{"totalmoneyspentnorm":"82.35812","moneypereligiblevoter":"2.468711","district":"1","nocontributionsnorm":"96.49426","votesperregisterednorm":"100","votespereligiblenorm":"77.19106","votesperregistered":".74878","moneypereligiblevoternorm":"64.65088","votespereligible":".6143688","totalmoneyspent":"1661028","nocontributions":"1800"},"3":{"totalmoneyspentnorm":"6.16484","moneypereligiblevoter":".4093141","district":"3","nocontributionsnorm":"11.14943","votesperregisterednorm":"87.63936","votespereligiblenorm":"55.56696","votesperregistered":".7213966","moneypereligiblevoternorm":"4.121686","votespereligible":".5756653","totalmoneyspent":"250594","nocontributions":"315"},"5":{"totalmoneyspentnorm":"100","moneypereligiblevoter":"3.671401","district":"5","nocontributionsnorm":"100","votesperregisterednorm":"66.71287","votespereligiblenorm":"24.89182","votesperregistered":".6750365","moneypereligiblevoternorm":"100","votespereligible":".520762","totalmoneyspent":"1987601","nocontributions":"1861"},"7":{"totalmoneyspentnorm":"16.90817","moneypereligiblevoter":".7899084","district":"7","nocontributionsnorm":"22.18391","votesperregisterednorm":"91.67287","votespereligiblenorm":"100","votesperregistered":".7303323","moneypereligiblevoternorm":"15.30801","votespereligible":".655193","totalmoneyspent":"449466.6","nocontributions":"507"},"9":{"totalmoneyspentnorm":"19.03839","moneypereligiblevoter":".8215308","district":"9","nocontributionsnorm":"38.21839","votesperregisterednorm":"66.79771","votespereligiblenorm":"63.45133","votesperregistered":".6752245","moneypereligiblevoternorm":"16.23744","votespereligible":".589777","totalmoneyspent":"488899.5","nocontributions":"786"},"11":{"totalmoneyspentnorm":"24.0489","moneypereligiblevoter":".8763332","district":"11","nocontributionsnorm":"35.45977","votesperregisterednorm":"55.68352","votespereligiblenorm":"35.39851","votesperregistered":".6506024","moneypereligiblevoternorm":"17.84818","votespereligible":".5395672","totalmoneyspent":"581650.4","nocontributions":"738"},"13":{"totalmoneyspentnorm":"45.43339","moneypereligiblevoter":"1.767386","district":"13","nocontributionsnorm":"69.54023","votesperregisterednorm":"78.13975","votespereligiblenorm":"68.40397","votesperregistered":".7003514","moneypereligiblevoternorm":"44.03775","votespereligible":".5986414","totalmoneyspent":"977504.2","nocontributions":"1331"},"15":{"totalmoneyspentnorm":"19.27474","moneypereligiblevoter":".9147846","district":"15","nocontributionsnorm":"28.50575","votesperregisterednorm":"56.48561","votespereligiblenorm":"26.95181","votesperregistered":".6523793","moneypereligiblevoternorm":"18.97833","votespereligible":".524449","totalmoneyspent":"493274.8","nocontributions":"617"},"17":{"totalmoneyspentnorm":"36.02762","moneypereligiblevoter":"1.30619","district":"17","nocontributionsnorm":"56.55172","votesperregisterednorm":"92.94174","votespereligiblenorm":"72.80564","votesperregistered":".7331433","moneypereligiblevoternorm":"30.4824","votespereligible":".6065196","totalmoneyspent":"803391.6","nocontributions":"1105"},"19":{"totalmoneyspentnorm":"80.7351","moneypereligiblevoter":"3.041245","district":"19","nocontributionsnorm":"99.02299","votesperregisterednorm":"93.98001","votespereligiblenorm":"72.1074","votesperregistered":".7354435","moneypereligiblevoternorm":"81.47865","votespereligible":".6052699","totalmoneyspent":"1630983","nocontributions":"1844"},"21":{"totalmoneyspentnorm":"0","moneypereligiblevoter":".2690811","district":"21","nocontributionsnorm":"0","votesperregisterednorm":"49.11674","votespereligiblenorm":"27.16907","votesperregistered":".6360545","moneypereligiblevoternorm":"0","votespereligible":".5248379","totalmoneyspent":"136475","nocontributions":"121"},"23":{"totalmoneyspentnorm":"18.5258","moneypereligiblevoter":".8506544","district":"23","nocontributionsnorm":"18.10345","votesperregisterednorm":"52.44405","votespereligiblenorm":"14.05868","votesperregistered":".6434258","moneypereligiblevoternorm":"17.09343","votespereligible":".5013725","totalmoneyspent":"479410.9","nocontributions":"436"},"25":{"totalmoneyspentnorm":"16.23976","moneypereligiblevoter":".6988137","district":"25","nocontributionsnorm":"12.58621","votesperregisterednorm":"57.72372","votespereligiblenorm":"47.26991","votesperregistered":".6551222","moneypereligiblevoternorm":"12.63058","votespereligible":".560815","totalmoneyspent":"437093.3","nocontributions":"340"},"27":{"totalmoneyspentnorm":"48.07119","moneypereligiblevoter":"1.745744","district":"27","nocontributionsnorm":"56.14943","votesperregisterednorm":"72.13197","votespereligiblenorm":"84.79749","votesperregistered":".6870419","moneypereligiblevoternorm":"43.40165","votespereligible":".627983","totalmoneyspent":"1026333","nocontributions":"1098"},"29":{"totalmoneyspentnorm":"33.98375","moneypereligiblevoter":"1.437288","district":"29","nocontributionsnorm":"37.41379","votesperregisterednorm":"33.82348","votespereligiblenorm":"40.3757","votesperregistered":".6021742","moneypereligiblevoternorm":"34.33559","votespereligible":".5484755","totalmoneyspent":"765556.9","nocontributions":"772"},"31":{"totalmoneyspentnorm":"22.54585","moneypereligiblevoter":"1.162735","district":"31","nocontributionsnorm":"15.86207","votesperregisterednorm":"37.36461","votespereligiblenorm":"18.03661","votesperregistered":".6100191","moneypereligiblevoternorm":"26.26603","votespereligible":".5084923","totalmoneyspent":"553827.1","nocontributions":"397"},"33":{"totalmoneyspentnorm":"18.20961","moneypereligiblevoter":"1.142543","district":"33","nocontributionsnorm":"10.57471","votesperregisterednorm":"0","votespereligiblenorm":"0","votesperregistered":".5272425","moneypereligiblevoternorm":"25.67254","votespereligible":".4762098","totalmoneyspent":"473557.9","nocontributions":"305"},"35":{"totalmoneyspentnorm":"16.70843","moneypereligiblevoter":".9259291","district":"35","nocontributionsnorm":"12.87356","votesperregisterednorm":"22.84129","votespereligiblenorm":"25.87839","votesperregistered":".5778446","moneypereligiblevoternorm":"19.30589","votespereligible":".5225278","totalmoneyspent":"445769.1","nocontributions":"345"},"37":{"totalmoneyspentnorm":"26.57476","moneypereligiblevoter":"1.025094","district":"37","nocontributionsnorm":"28.90805","votesperregisterednorm":"51.79779","votespereligiblenorm":"74.50986","votesperregistered":".6419941","moneypereligiblevoternorm":"22.22051","votespereligible":".6095699","totalmoneyspent":"628407.2","nocontributions":"624"},"39":{"totalmoneyspentnorm":"28.57493","moneypereligiblevoter":".9708326","district":"39","nocontributionsnorm":"19.08046","votesperregisterednorm":"82.00311","votespereligiblenorm":"42.31423","votesperregistered":".7089102","moneypereligiblevoternorm":"20.62568","votespereligible":".5519451","totalmoneyspent":"665432.9","nocontributions":"453"}}
18 changes: 15 additions & 3 deletions public/js/counties-overlay.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
var layer;
var data;
var layer_data;
var scale = d3.scale.linear();
scale.domain([1,100]).rangeRound([1,10]);

function addOverlay(house) {

var svg = d3.select(map.getPanes().overlayPane).append("svg"),
g = svg.append("g").attr("class", "leaflet-zoom-hide");

var layer_data;
$.getJSON(data_dir+"ca/data-"+house+".json", function(data) {
layer_data = data;
console.log($.parseJSON(layer_data.responseText));
});

d3.json(data_dir+"/ca/bound-"+house+".json", function(collection) {
Expand All @@ -21,7 +22,18 @@ function addOverlay(house) {
.enter()
.append("path")
.attr('data-name', function(d){ return d.properties.name })
.on('mouseover',function(d){ $("#mouseinfo").text(d.properties.name) });
.attr('class', function(d){var blah = scale( layer_data[d.properties.district]["votesperregisterednorm"] ); return 'apathy-'+blah; })
.on('mouseover',function(d){
vpe = (layer_data[d.properties.district]["votespereligible"] * 100).toFixed(0);
vpr = (layer_data[d.properties.district]["votesperregistered"] * 100).toFixed(0);
$("#mouseinfo").html(d.properties.name + "<br/>" +
"$/eligible: " + layer_data[d.properties.district]["moneypereligiblevoter"] + "<br/>" +
"# Contributions: " + layer_data[d.properties.district]["nocontributions"] + "<br/>" +
"Total spent: $" + layer_data[d.properties.district]["totalmoneyspent"] + "<br/>" +
"Votes/eligible: " + vpe + "%" + "<br/>" +
"Votes/registered: " + vpr + "%"
);
});

map.on("viewreset", reset);
reset();
Expand Down
4 changes: 2 additions & 2 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var map,
(function($){
map = L.map('map',{maxZoom: 19});
layer = new L.StamenTileLayer("toner-lite");
map.addLayer(layer).locate({setView: true, maxZoom: 16});
map.addLayer(layer).locate({setView: true, maxZoom: 7});
$('#splash button').click(function(e){
e.preventDefault();
$('#splash').hide();
Expand All @@ -16,4 +16,4 @@ var map,
$('body').removeClass('footer-up')
}
);
})($);
})($);
4 changes: 2 additions & 2 deletions scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def get_shape(leg_id):
outfile.write(json.dumps(assembly_short_json))
outfile.close"""

csvfile = open('public/data/senatefileready.csv')
csvfile = open('public/data/assemblyfileready.csv')
outjson = []
outfile = open('public/data/ca/data-u.json','w')
outfile = open('public/data/ca/data-l.json','w')
csvwriter = csv.DictReader(csvfile)

for row in csvwriter:
Expand Down
2 changes: 2 additions & 0 deletions templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
OH HAI
</div>
<div class="inner">
<a class="locationer" href="#">List</a>
<a class="lister" href="#">List</a>
</div>

0 comments on commit e31d44f

Please sign in to comment.