🌍 Public
Viewing a saved revision (read-only)
41f987767d3e4af4acf3767b1495c82d
Responding to Resize
This example demonstrates how a D3.js visualization can automatically adapt to changes in the browser window’s size. Using CSS to fill the page, the chart extracts its container’s client dimensions and redraws the SVG element accordingly. The code employs `d3.select` and attributes like `attr("width")` to resize the graphic, then draws two intersecting lines forming an X with `style("stroke", "green")`. A `window.addEventListener("resize", redraw)` callback triggers the redraw whenever the viewport changes, ensuring the visualization remains correctly scaled.
AI-generated description