Responding to Resize
✓ Published0🌍 Public
This example shows a single SVG that dynamically redraws a large green X to fit the full browser window whenever the viewport changes. It uses plain JavaScript to listen for the window’s resize event, then reads the container’s clientWidth and clientHeight to update the SVG’s width and height attributes. A D3 v5 data join binds two line objects to render the diagonal strokes, merging enter and update selections to adjust coordinates. The chart fills the page via fixed CSS positioning, and no external data source is used.
AI-generated descriptionMIT Licensed