Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Viewing a saved revision (read-only)

f31e4e50ac154f1cb6010ce86c5a1a95

Responding to Resize

0 stars1🌍 Public
Kking-seo
Last edited Aug 28, 2019
Created on Aug 28, 2019

This example demonstrates how a D3.js visualization can respond dynamically to browser resizing. A green X-shaped pair of lines is drawn across the full viewport, with the SVG dimensions updated to match the CSS-computed container size on every resize event. The code uses `chartDiv.clientWidth` and `chartDiv.clientHeight` within a `redraw` function, triggered initially and via `window.addEventListener("resize", redraw)`. The SVG is created with `d3.select`, and lines are bound to data arrays and updated using the merge pattern.

AI-generated description