Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Viewing a saved revision (read-only)

d9d63c56be6744c7b1da9901e2890357

Responding to Resize

0 stars0🌍 Public
AAdira4300
Last edited Apr 5, 2020
Created on Apr 5, 2020

This example demonstrates how a D3.js visualization can adapt to browser resizing by redrawing an SVG to fill the available viewport. A green, semi-transparent X is rendered across the entire chart area, with its coordinates recalculated on every window resize event. The code uses `d3.select` to manage the SVG element and the native `window.addEventListener("resize")` to trigger the redraw function, which reads the container’s `clientWidth` and `clientHeight` to set the SVG’s dimensions. The data comes from a CSV file, though it is only logged to the console and not visualized here.

AI-generated description