Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Viewing a saved revision (read-only)

f2fe596a1c9b4516ace8107c82ac9a0d

Responding to Resize

0 stars0🌍 Public
JjimacDS
Last edited Jun 15, 2020
Created on Jun 15, 2020

This example demonstrates how a D3.js v5 visualization can respond dynamically to browser window resizing. It uses a full-screen chart container and redraws an SVG element to match the container’s current pixel dimensions, displaying a green X composed of two thick lines. The code leverages `d3.select`, `svg.attr`, and a window `resize` event listener to update the drawing. The visualization extracts dimensions via `clientWidth` and `clientHeight`, ensuring the SVG scales proportionally with the viewport.

AI-generated description