Skip to main content
100%

Fitted Symbols (d3v4)

✓ Published0🌍 Public
PPhilippe Rivière
Last edited Apr 26, 2019
Created on Nov 8, 2016

This example cycles through a sequence of D3 symbols, scaling each one to fit precisely within a fixed rectangular bounding box. It uses `d3.symbol` and `d3.symbols` to generate the shapes, and `getBBox()` on the SVG path to measure the symbol’s actual footprint. A `setInterval` loop selects a new symbol every two seconds, then employs a `transition` on the path’s `d` attribute to animate the scaling over 1.5 seconds. The code renders with SVG and leverages the D3 v4 API from `https://d3js.org/d3.v4.min.js`.

AI-generated description

This example demonstrates how to scale a D3 symbol to fit inside a specified rectangular bounding box using getBBox.

forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/3dd515e692504c92ab65'>Fitted Symbols (d3v3)</a>

gpl-3.0 Licensed

Similar vizzes