🌍 Public
Viewing a saved revision (read-only)
5f7b6f6f077f48459681ff63855bfd4e
Responding to Resize
This example demonstrates how a D3.js visualization can respond to browser resizing by redrawing its content to match the new dimensions. The page uses a CSS-styled container and a redraw function that reads `clientWidth` and `clientHeight` to set the SVG’s `width` and `height` attributes. It draws two green lines forming an X across the full viewport, with strokes updated on each resize event. The code uses D3 v5 with `d3.select`, `svg.attr`, and `window.addEventListener` to handle the dynamic resizing.
AI-generated description