Skip to main content
100%

Responding to Resize

✓ Published0🌍 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
MIT Licensed

Similar vizzes