Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Responding to Resize

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

Comments

Sign in to join the discussion.

MIT Licensed