Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Viewing a saved revision (read-only)

1d3c4bcdd5154ed8b2a44d89991d34c9

Responding to Resize

0 stars0🌍 Public
Jjugsomilk
Last edited Apr 22, 2020
Created on Apr 22, 2020

This example demonstrates how a D3.js visualization can respond to browser window resizing. It draws a green X composed of two thick, semi-transparent lines that stretch across the entire viewport, with the SVG element filling the page via CSS fixed positioning. The code uses `chartDiv.clientWidth` and `clientHeight` to extract the computed CSS size, then applies those dimensions to the SVG’s width and height attributes. A `redraw` function manages the SVG and line updates, and a window `resize` event listener triggers it whenever the viewport changes.

AI-generated description