Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Responding to Resize

0 stars0🌍 Public
TTheRedUnicorn
Last edited Jul 18, 2019
Created on Jul 18, 2019

This example demonstrates a chart that responds to browser resizing by redrawing its content to match the available space. It shows a large green X drawn across the entire viewport, with the SVG dimensions updating dynamically as the window changes. The code uses the D3 v5 library to bind an SVG element to a fixed-position container, then recalculates the width and height from the container's `clientWidth` and `clientHeight` properties on every resize event. A `redraw()` function defines two diagonal lines and updates their endpoints via D3's selection-merging API, while a window listener triggers the redraw.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed