Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Viewing a saved revision (read-only)

e0cbf7d6b0ee48359ddc6d053f9124e3

Responding to Resize

0 stars0🌍 Public
Mmyskotima130
Last edited Feb 25, 2020
Created on Feb 25, 2020

This example demonstrates how a D3.js visualization can respond to browser window resizing. It uses a CSS-styled container that fills the viewport, and a redraw function extracts the container’s current clientWidth and clientHeight to update the SVG dimensions. Two green, semi-transparent lines are drawn across the full width and height to form an X, visually confirming the resized area. The code relies on window.addEventListener("resize", redraw) and D3’s selection.merge pattern to update the existing line elements efficiently.

AI-generated description