Built with blockbuilder.org
Last active
November 3, 2017 02:35
-
-
Save seschultz/700db82b82d91e841c7413b006de311d to your computer and use it in GitHub Desktop.
project
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
license: mit |
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
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://d3js.org/topojson.v2.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
</style> | |
</head> | |
<body> | |
<script> | |
// Feel free to change or delete any of the code you see in this editor! | |
/*var svg = d3.select("body").append("svg") | |
.attr("width", 960) | |
.attr("height", 500) | |
svg.append("text") | |
.text("Edit the code below to change me!") | |
.attr("y", 200) | |
.attr("x", 120) | |
.attr("font-size", 36) | |
.attr("font-family", "monospace")*/ | |
d3.json("Allegheny_County_Census_Tracts_2016.geojson", function(json){ | |
// Loop through each state data value in the .csv file | |
for (var i = 0; i < data.length; i++) { | |
// Grab census tract | |
var dataState = data[i].censusTract; | |
// Grab data value | |
var dataValue = data[i].value; | |
// Find the corresponding state inside the GeoJSON | |
for (var j = 0; j < json.features.length; j++) { | |
var jsonState = json.features[j].properties.name; | |
if (dataState == jsonState) { | |
// Copy the data value into the JSON | |
json.features[j].properties.value = dataValue; | |
// Stop looking through the JSON | |
break; | |
} | |
} | |
} | |
}) | |
// d3.queue() | |
// .defer(d3.json, "Allegheny_County_Census_Tracts_2016.geojson") | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment