Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Responding to Resize

0 stars0🌍 Public
LLittledevil7
Last edited Apr 18, 2020
Created on Apr 18, 2020

A chart automatically resizes to fill the browser window by reading the CSS-computed dimensions of its container. The code uses d3.v5 to select the container div and append an SVG, then redraws an X made of two green lines whenever the window fires a resize event. It retrieves the container's clientWidth and clientHeight to set the SVG's width and height attributes, ensuring the graphic always matches the viewport.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed