🌍 Public
Viewing a saved revision (read-only)
eddff7bde83d43f381897c4cdecd9d6b
Responding to Resize
This example demonstrates how a D3.js visualization can adapt to browser window resizing. It uses the CSS `position: fixed` to make the chart container fill the viewport, then extracts the container’s `clientWidth` and `clientHeight` to set the SVG’s width and height attributes on each resize event. A green X is drawn using SVG `<line>` elements and the `selection.merge()` method, with both lines re-rendered to span the full dimensions. The code relies on `d3.select` and the `window.addEventListener("resize", redraw)` API to trigger updates.
AI-generated description