🌍 Public
Viewing a saved revision (read-only)
7c19dfe6efb54f269be02983fd6e2b4b
Fork of Responding to Resize
This example demonstrates a responsive SVG visualization that fills the entire browser window and redraws its content whenever the viewport size changes. It shows two thick, semi-transparent green lines forming an X across the full width and height of the chart container. The code uses D3 v5 to select the `#chart` div, append an SVG element, and bind line data to render the X. A `redraw` function reads the container’s `clientWidth` and `clientHeight` to update the SVG’s dimensions, then repositions the lines via the `merge` pattern. The `window.addEventListener("resize", redraw)` triggers this responsive behavior.
AI-generated description