Skip to main content
100%

Example of Dynamically Resizing SVG Canvas and Shapes

✓ Published0🌍 Public
GGuerino1
Last edited Jul 6, 2016
Created on Jul 6, 2016

This example shows SVG shapes—four semi-transparent colored circles and several thick maroon lines—that dynamically resize to match the browser window's dimensions. The visualization uses a fixed-position `#chart` div, with CSS determining the available space. On each window resize event, the `draw()` function reads `clientWidth` and `clientHeight` to update the SVG canvas size and recalculate shape positions and radii. The code relies on the d3.js library (version 2.4.5) for SVG element selection, data binding, and attribute updates, with data drawn from a hardcoded array of circle definitions.

AI-generated description

Similar vizzes