🌍 Public
Viewing a saved revision (read-only)
d8f1a91cf731401d9ffa86bd2c77f6e7
Responding to Resize
This example demonstrates a D3.js visualization that dynamically resizes an SVG graphic to match its container’s dimensions. The page’s CSS fixes the chart div to fill the viewport, and the `redraw` function reads `clientWidth` and `clientHeight` to update the SVG’s width and height attributes. It then draws two green, semi-transparent diagonal lines forming an X, whose endpoints are recalculated on every resize. The code uses the browser’s `resize` event listener to invoke `redraw`, alongside D3’s data join for efficient line updates.
AI-generated description