🌍 Public
Viewing a saved revision (read-only)
2677ebc1898f4137955d2406f513f4fa
Responding to Resize
This example demonstrates a full-window SVG chart that automatically redraws itself whenever the browser window is resized. The code uses CSS fixed positioning to make a container div fill the viewport, then reads its `clientWidth` and `clientHeight` properties inside a `redraw()` function. It sets the SVG’s `width` and `height` attributes accordingly and renders two diagonal green lines forming an X, using the data-join pattern with `svg.selectAll("line").data()` and the `merge()` method. A global `resize` event listener triggers the redraw on every window size change.
AI-generated description