Skip to main content
100%

Fork of Responding to Resize

✓ Published0🌍 Public
Aaksniks
Last edited Feb 3, 2021
Created on Feb 3, 2021

This example demonstrates a full-window SVG that redraws an X shape whenever the browser viewport changes size. It uses a CSS-fixed `#chart` container to compute the available width and height via `clientWidth` and `clientHeight`, then updates the SVG’s `width` and `height` attributes inside a `redraw()` function. The code attaches a `window` `resize` event listener to call `redraw()` continuously, ensuring the two thick green lines always span the new dimensions. Built with D3 v5, it selects elements with `d3.select` and uses the `merge` method to update the line positions.

AI-generated description
MIT Licensed

Similar vizzes