Skip to main content
100%

Responding to Resize

✓ Published0🌍 Public
Aantoinecarto
Last edited Jul 11, 2019
Created on Jul 11, 2019

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 description
MIT Licensed

Similar vizzes