Skip to content

Instantly share code, notes, and snippets.

@veev
Created December 19, 2013 23:44
Show Gist options
  • Save veev/8048189 to your computer and use it in GitHub Desktop.
Save veev/8048189 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Stats Test Open Spaces</title>
<script type="text/javascript" src="js/vendor/d3.v3.min.js"></script>
<script type="text/javascript" src="js/vendor/topojson.v1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<h1>Park Stats</h1>
<div id="park-list"><div/>
<div id="park-foursquare"></div>
<script type="text/javascript">
$.getJSON('data/park_shapes.json', function(data) {
console.log(data);
var output = "<div class='park-stats'>";
for( var i in data.features) {
//var noNullCheckins = data.features[i].properties.checkinscount || "0";
//var noNullVeneus = data.features[i].properties.venuecount || "0";
output += "<div class='park-stats'>" +
"<h2 class='hashtag-list'>#" + data.features[i].properties.hashtag + "</h2>" +
"<h2 class='parkname-list'>" + data.features[i].properties.unit_name + "</h2>" +
"<p class='content-list'>" + data.features[i].properties.unit_acres + " acres</p>" +
//"<p class='content-list'>" + commaSeparateNumber(noNullCheckins) + " check-ins</p>" +
//"<p class='content-list'>" + noNullVeneus + " venues</p>" +
"</div>";
}
output += "</div>";
document.getElementById("park-list").innerHTML = output;
});
$.getJSON('data/superunits_hashtags_counts2.topojson', function(data) {
console.log(data);
var output = "<div class='park-stats'>";
for( var i in data.objects.superunits_hashtags_counts2.geometries) {
var noNullCheckins = data.objects.superunits_hashtags_counts2.geometries[i].properties.checkinscount || "0";
var noNullVeneus = data.objects.superunits_hashtags_counts2.geometries[i].properties.venuecount || "0";
output += "<div class='park-stats'>" +
//"<h2 class='hashtag-list'>#" + data.objects.superunits_hashtags_counts2.geometries[i].properties.hashtag + "</h2>" +
//"<h2 class='parkname-list'>" + data.objects.superunits_hashtags_counts2.geometries[i].properties.unit_name + "</h2>" +
"<p class='content-list'>" + commaSeparateNumber(noNullCheckins) + " check-ins</p>" +
"<p class='content-list'>" + noNullVeneus + " venues</p>" + "</div>";
}
output += "</div>";
document.getElementById("park-foursquare").innerHTML = output;
});
//d3.json("data/superunits_hashtags_counts2.topojson"
function commaSeparateNumber(val){
while (/(\d+)(\d{3})/.test(val.toString())){
val = val.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2');
}
return val;
}
// var path = d3.geo.path().projection(projection);
// d3.json("data/superunits_hashtags_counts2.topojson", function(error, units) {
// svg.selectAll("path")
// .data(json.features)
// .enter()
// }
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment