Skip to main content
100%

Responding to Resize

✓ Published0🌍 Public
Ddbidwai
Last edited Nov 22, 2020
Created on Nov 22, 2020

This example demonstrates how a D3 v5 SVG visualization can dynamically respond to browser window resizing. It draws a large green X spanning the full viewport, with the chart container filling the page via fixed CSS positioning. The `redraw` function reads the container’s `clientWidth` and `clientHeight` to update the SVG’s width and height attributes, then repositions two `<line>` elements using a data join. A `window` resize event listener triggers `redraw` on every size change, ensuring the graphic always matches the available space.

AI-generated description
MIT Licensed

Similar vizzes