Built with blockbuilder.org
Created
March 2, 2018 02:07
-
-
Save piwodlaiwo/281f0eebcf2ee35d7fc2c08b2d5315e4 to your computer and use it in GitHub Desktop.
D3v4 using unpkg
This file contains hidden or 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 hidden or 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> | |
<meta charset="utf-8"> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
svg { width:100%; height: 100% } | |
</style> | |
<body> | |
<script src="https://unpkg.com/d3@4"></script> | |
<script src="https://unpkg.com/d3-geo-projection@2"></script> | |
<script src="https://unpkg.com/topojson-client@3"></script> | |
<script> | |
var width = 900; | |
var height = 500; | |
var svg = d3.select("body").append("svg") | |
var projection = d3.geoMercator(); | |
var path = d3.geoPath().projection(projection); | |
d3.json("https://unpkg.com/world-atlas@1/world/50m.json", function(error, world) { | |
if (error) throw error; | |
svg.selectAll("path") | |
.data(topojson.feature(world, world.objects.countries).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