Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Viewing a saved revision (read-only)

1694b604db7d464bbf283936e08e4a62

Responding to Resize

0 stars0🌍 Public
Mminimartzz
Last edited Oct 31, 2019
Created on Oct 31, 2019

This example demonstrates how a D3.js visualization can respond dynamically to browser resizing. It shows a large green X spanning the entire viewport, where the lines are drawn based on the current window dimensions. The code uses D3 v5 with SVG rendering, fetching the container’s client width and height via `clientWidth` and `clientHeight`, then updating the SVG attributes accordingly. A resize event listener triggers the `redraw` function whenever the window size changes.

AI-generated description