Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Responding to Resize

0 stars0🌍 Public
JJialin Wu
Last edited Aug 12, 2019
Created on Aug 12, 2019

This example demonstrates a full-page SVG visualization that responds to browser resizing by redrawing a large green X spanning the chart’s diagonal corners. The code uses a fixed-position div container with CSS to compute available space, then extracts its `clientWidth` and `clientHeight` inside a `redraw()` function. That function updates the SVG’s `width` and `height` attributes and binds two line data points to draw the X. A `window.addEventListener("resize", redraw)` triggers the redraw on every window size change, while d3.v5 manages SVG element selection and data joins.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed