Created
September 14, 2019 14:57
-
-
Save FrieseWoudloper/95253635fef2006c77923f8f04148e1b to your computer and use it in GitHub Desktop.
USA in v3
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> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<div class="graph"></div> | |
<script> | |
var width = 700, height = 400; | |
var svg = d3.select(".graph").append("svg") | |
.attr("viewBox", "0 0 " + (width) + " " + (height)) | |
.style("max-width", "700px"); | |
var url = "https://gist.githubusercontent.com/michellechandra/0b2ce4923dc9b5809922/raw/a476b9098ba0244718b496697c5b350460d32f99/us-states.json"; | |
d3.json(url, function(error, mapdata) { | |
var projection = d3.geoAlbersUsa() | |
.translate([width / 2, height / 2]) // translate to center of screen | |
.scale([1000]); // scale things down so see entire US | |
var path = d3.geoPath().projection(projection); | |
svg.append("g") | |
.attr("class", "gemeente") | |
.selectAll("path") | |
.data(mapdata.features) | |
.enter() | |
.append("path") | |
.attr("d", path); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment