Skip to main content
100%

Responding to Resize

✓ Published0🌍 Public
TTrey Billing
Last edited Aug 22, 2019
Created on Aug 22, 2019

This example demonstrates how a D3.js visualization can adapt to browser window resizing. It uses the CSS `position: fixed` to make the chart container fill the viewport, then extracts the container’s `clientWidth` and `clientHeight` to set the SVG’s width and height attributes on each resize event. A green X is drawn using SVG `<line>` elements and the `selection.merge()` method, with both lines re-rendered to span the full dimensions. The code relies on `d3.select` and the `window.addEventListener("resize", redraw)` API to trigger updates.

AI-generated description
MIT Licensed

Similar vizzes