Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

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

Comments

Sign in to join the discussion.

MIT Licensed