Skip to content

Instantly share code, notes, and snippets.

@sergeiwallace
Forked from mbostock/.block
Last active July 15, 2018 19:47
Show Gist options
  • Save sergeiwallace/81f25fd354a8c1ae4d6e28147ee27a35 to your computer and use it in GitHub Desktop.
Save sergeiwallace/81f25fd354a8c1ae4d6e28147ee27a35 to your computer and use it in GitHub Desktop.
US District Map using d3.geoPath + Canvas
license: gpl-3.0
height: 600
border: no
<!DOCTYPE html>
<canvas width="960" height="600"></canvas>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://unpkg.com/topojson-client@3"></script>
<script>
var context = d3.select("canvas").node().getContext("2d"),
path = d3.geoPath().context(context);
d3.json("https://unpkg.com/us-atlas@1/us/10m.json", function(error, us) {
if (error) throw error;
context.beginPath();
path(topojson.mesh(us));
context.stroke();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment