Responding to Resize
✓ Published0🌍 Public
This example demonstrates a simple, responsive SVG visualization that adapts to the browser window's size. It draws two thick green lines forming an X across the entire viewport, illustrating how CSS-computed dimensions are used to redraw the graphic on window resizing. The D3 v5 code, using `d3.select`, extracts the container's `clientWidth` and `clientHeight` to update the SVG's `width` and `height` attributes, then repositions the line elements via the `merge` operation. A `window.addEventListener("resize")` handler triggers the `redraw` function whenever the window changes.
AI-generated descriptionMIT Licensed