Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Responding to Resize

0 stars0🌍 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

Comments

Sign in to join the discussion.

MIT Licensed