Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Viewing a saved revision (read-only)

417b96c8b1404fe4a29a9fc8e7422c2a

Responding to Resize

0 stars0🌍 Public
Jjesramyep1263
Last edited Mar 21, 2020
Created on Mar 21, 2020

This example demonstrates an SVG visualization that fills the browser window and redraws its content whenever the window is resized. It shows a green X shape composed of two crossing lines, whose coordinates are recalculated to match the container's current dimensions. The code uses `d3.select` to append an SVG element and relies on CSS `position: fixed` with `clientWidth` and `clientHeight` to determine the size. Window resize events trigger the `redraw` function, which updates the SVG's width, height, and line positions using D3's `.attr` methods.

AI-generated description