Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Fork of Responding to Resize

Public visualization

Fork of Responding to Resize

0 stars0🌍 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

Comments

Sign in to join the discussion.

MIT Licensed