Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Responding to Resize

0 stars0🌍 Public
VVijay2051
Last edited Jul 8, 2019
Created on Jul 8, 2019

This example demonstrates how a visualization can dynamically respond to browser window resizing. It shows a green X shape that stretches and scales to fill the entire viewport, using an SVG canvas. The code uses CSS to size a chart container and then extracts its computed dimensions via `clientWidth` and `clientHeight`. A `redraw` function updates the SVG’s width and height attributes and redraws two intersecting lines. A window `resize` event listener triggers this function, ensuring the graphic always matches the current viewport size. It uses D3.js v5 for SVG element creation and manipulation.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed