Skip to content

svg

The SVG backend and publication-quality vector export. SvgBackend renders render layers as SVG, SvgPathContext is a core!PathContext that records path d strings, and svgDocument / svgFromLayers serialize geometry to a standalone SVG document.

import { svgFromLayers } from "@mapequation/d3gl/svg";
const svg = svgFromLayers(layers, { width, height }); // serializable SVG string
ClassDescription
SvgBackendA renderer for a Scene, implemented per target (WebGL / Canvas / SVG).
SvgPathContextA PathContext that accumulates an SVG path d string. Used for publication vector export: re-run a d3 generator (geoPath, d3-shape, …) into this context and read toPath(). Curves map to native C/Q commands; arcs are flattened to line segments (correct geometry; geo export is polygons/lines, so this is rare).
InterfaceDescription
SvgPathOne styled path in an SVG document.
FunctionDescription
svgDocumentAssemble styled paths into a standalone SVG document string. Paths with an empty d are skipped. fill defaults to “none” when only a stroke is given, otherwise to the provided fill.
svgFromLayersA full SVG document for the given layers under a view transform.