Skip to content

Instantly share code, notes, and snippets.

@Andrew-Reid
Created November 23, 2017 05:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andrew-Reid/7edb496a7b6a51f17cbec8c3431c8551 to your computer and use it in GitHub Desktop.
Save Andrew-Reid/7edb496a7b6a51f17cbec8c3431c8551 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>D3: Setting path fills</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.10.0/d3.min.js"></script>
<style type="text/css">
/* styles */
</style>
</head>
<body>
<script type="text/javascript">
var svg = d3.select("body").append("svg")
.attr("width", 760)
.attr("height", 700)
d3.json("canada.json", function(data) {
var group = svg.selectAll("g")
.data(data.features)
.enter()
.append("g")
var projection = d3.geoMercator();
var path = d3.geoPath().projection(projection);
var areas = group.append("path")
.attr("d",path)
.attr("class","area")
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment