Skip to content

Instantly share code, notes, and snippets.

@yosiasz
Created April 24, 2016 00:24
Show Gist options
  • Save yosiasz/52ee9a4be804347afe3f3391bb6887d6 to your computer and use it in GitHub Desktop.
Save yosiasz/52ee9a4be804347afe3f3391bb6887d6 to your computer and use it in GitHub Desktop.
Africa
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
fill: #ccc;
stroke: #fff;
stroke-width: .5px;
}
path:hover {
fill: red;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//d3js.org/topojson.v1.min.js"></script>
<script>
var width = 960,
height = 500;
var path = d3.geo.path();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("ethiopia.json", function(error, topology) {
if (error) throw error;
console.log(topology);
svg.selectAll("path")
.data(topojson.feature(topology, topology.objects.regions).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