D3’s d3.geoPath can be used with Canvas, not just SVG! This geometry is from us-atlas.
Forked from Mike Bostock https://gist.github.com/mbostock/3783604
license: gpl-3.0 | |
height: 600 | |
border: no |
D3’s d3.geoPath can be used with Canvas, not just SVG! This geometry is from us-atlas.
Forked from Mike Bostock https://gist.github.com/mbostock/3783604
<!DOCTYPE html> | |
<canvas width="1920" height="1200" style="width: 960px; height: 600px;"></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.scale(2,2); | |
context.beginPath(); | |
path(topojson.mesh(us)); | |
context.stroke(); | |
}); | |
</script> |