Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Viewing a saved revision (read-only)

7eb16221dcbf4a8296d1063f095fab09

Responding to Resize

6 stars227🌍 Public
CCurran Kelleher
Last edited Dec 29, 2019
Created on Aug 30, 2018
Forked from Face in d3

This example demonstrates how a visualization can dynamically respond to browser window resizing. It uses the CSS `clientWidth` and `clientHeight` properties to extract the current container size and applies these dimensions to an SVG element via the `attr` method. Two diagonal lines are drawn across the SVG to visually confirm the correct sizing, with a resize event listener triggering a full redraw. The code relies on D3 v5’s selection and data join patterns to update the line coordinates.

AI-generated description