Skip to main content
100%

Responding to Resize

✓ Published0🌍 Public
Jjulieducasse
Last edited Sep 19, 2019
Created on Sep 19, 2019

This example demonstrates how a D3.js visualization can respond to browser window resizing. A green X is drawn across the full viewport, with its lines recalculated to match the current window dimensions. The code uses the `clientWidth` and `clientHeight` properties of a div container to set the SVG element's width and height attributes. A `redraw` function is invoked on the `resize` event, regenerating the line positions with a data join using `selectAll` and `merge`.

AI-generated description
MIT Licensed

Similar vizzes