Skip to main content
100%

d3.geoPath + Canvas

✓ Published0🌍 Public
FFrissAnalytics
Last edited Sep 18, 2018
Created on Sep 18, 2018

This example renders the U.S. state boundaries from the `us-atlas` TopoJSON file onto an HTML5 Canvas element. It uses `d3.geoPath` with a Canvas context to draw the map, demonstrating that this projection API works outside of SVG. The code fetches the geographic data from `10m.json`, converts it with `topojson.mesh`, and strokes the resulting paths with a single `beginPath` and `stroke` call. The approach eliminates SVG overhead by relying on Canvas rendering.

AI-generated description

D3’s d3.geoPath can be used with Canvas, not just SVG! This geometry is from us-atlas.

forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/3783604'>d3.geoPath + Canvas</a>

gpl-3.0 Licensed

Similar vizzes