Skip to main content
100%

Responding to Resize

✓ Published0🌍 Public
DDeepanshuu
Last edited Jul 16, 2019
Created on Jul 16, 2019

This example demonstrates how a D3.js visualization can adapt to browser window resizing. A full-page SVG displays a green X composed of two thick lines that stretch to match the container’s current dimensions. The code uses a `redraw` function to read `clientWidth` and `clientHeight` from the chart’s `div`, then updates the SVG’s width and height attributes and the line coordinates via a data join. A native `window` `resize` event listener triggers a redraw whenever the viewport changes.

AI-generated description
MIT Licensed

Similar vizzes