Skip to main content
100%

Responding to Resize

✓ Published0🌍 Public
Kkenneth
Last edited Sep 17, 2019
Created on Sep 17, 2019

This example demonstrates how a D3.js visualization can dynamically adjust to its container’s size by redrawing an SVG graphic on every browser resize event. The chart fills the entire page via CSS and uses `clientWidth` and `clientHeight` to set the SVG’s width and height attributes. It draws two crossed green lines with `stroke-width` and `stroke-opacity` to visually confirm that the resized dimensions are correct. The `redraw` function is called initially and then re-invoked through a `window` resize listener.

AI-generated description
MIT Licensed

Similar vizzes