Skip to main content
100%

Fork of Responding to Resize

✓ Published0🌍 Public
HHojjat Karami
Last edited Mar 24, 2023
Created on Mar 24, 2023

This example demonstrates a responsive SVG visualization that adapts to its container’s size by drawing a large green X across the full viewport. The chart fills the page via CSS positioning, and a JavaScript `redraw` function reads the container’s `clientWidth` and `clientHeight` on every window resize event. Using D3 v5, it binds an array of two line coordinates to SVG `line` elements, updating their endpoints and stroke properties dynamically. The code explicitly sets the SVG’s width and height attributes to match the measured dimensions, ensuring the graphic always spans the available space.

AI-generated description
MIT Licensed

Similar vizzes