Skip to main content
100%

d3.geoPath + Canvas

✓ Published0🌍 Public
Mmbostock
Last edited Mar 22, 2019
Created on Sep 25, 2012

This example displays a map of the United States drawn entirely on a Canvas element. It shows how D3’s `d3.geoPath` can render geographic data into a native Canvas context rather than an SVG, with the map’s geometry provided by the `us-atlas` dataset. The code uses `d3.json` to load the TopoJSON file and `topojson.mesh` to convert it into renderable shapes. The resulting path is stroked onto the canvas via the `context` set on `d3.geoPath`, demonstrating a performant alternative to SVG for large spatial datasets.

AI-generated description

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

gpl-3.0 Licensed

Similar vizzes