Skip to main content
100%

Fork of Responding to Resize

✓ Published0🌍 Public
Zzcz-hjy
Last edited May 18, 2021
Created on May 18, 2021

This example demonstrates a full-page SVG that redraws itself whenever the browser window is resized, using a green X spanning the chart’s diagonal as a visual test of the updated dimensions. The code extracts the CSS-computed `clientWidth` and `clientHeight` from the container `<div>`, then sets the SVG’s `width` and `height` attributes accordingly. It uses d3 v5’s data join (`selectAll`, `enter`, `merge`) to update two `<line>` elements, and registers a `resize` event listener on `window` to call the `redraw` function on every size change.

AI-generated description
MIT Licensed

Similar vizzes