Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Responding to Resize

0 stars0🌍 Public
Sshalinirp
Last edited Dec 14, 2019
Created on Dec 14, 2019

This example demonstrates how a D3.js visualization can automatically adapt to browser resizing. It renders a full-screen green X composed of two intersecting lines, with the SVG dimensions recalculated on every window resize event. The code uses the `d3.select` API to manage the SVG element and data-joins with `merge()` to update line coordinates. The chart container fills the viewport via CSS positioning, and the `clientWidth` and `clientHeight` properties supply the current size to the `redraw` function, which is called initially and again on each resize event.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed