Skip to main content
100%

Responding to Resize

✓ Published0🌍 Public
Sstelson
Last edited Apr 27, 2020
Created on Apr 27, 2020

This example demonstrates an SVG chart that automatically adjusts its size to fill the browser window, drawing a simple green X to visually confirm the layout. It uses D3 v5 to select the container div and append an SVG element, then defines a `redraw` function that reads the container’s `clientWidth` and `clientHeight` to set the SVG’s width and height attributes. A resize event listener triggers `redraw` on every window size change, while `selectAll` and data joins update the two diagonal line elements.

AI-generated description
MIT Licensed

Similar vizzes