Skip to main content
100%

Responding to Resize

✓ Published0🌍 Public
Jjesramyep1263
Last edited Mar 21, 2020
Created on Mar 21, 2020

This example demonstrates an SVG visualization that fills the browser window and redraws its content whenever the window is resized. It shows a green X shape composed of two crossing lines, whose coordinates are recalculated to match the container's current dimensions. The code uses `d3.select` to append an SVG element and relies on CSS `position: fixed` with `clientWidth` and `clientHeight` to determine the size. Window resize events trigger the `redraw` function, which updates the SVG's width, height, and line positions using D3's `.attr` methods.

AI-generated description
MIT Licensed

Similar vizzes