Skip to main content
100%

Responding to Resize

✓ Published0🌍 Public
AAnton Bodnya
Last edited Jul 16, 2019
Created on Jul 16, 2019

This example demonstrates a responsive D3.js visualization that adapts automatically when the browser window is resized. It shows a large green X drawn across an SVG canvas that fills the entire viewport. The code uses the `clientWidth` and `clientHeight` properties of the chart container to measure the CSS-computed dimensions, then applies those values to the SVG via `attr("width")` and `attr("height")`. A `redraw` function, triggered by a `resize` event listener, re-renders the X marks to match the updated size.

AI-generated description
MIT Licensed

Similar vizzes