Skip to main content
100%

Responding to Resize

✓ Published1🌍 Public
TTheRoadSign
Last edited Nov 25, 2019
Created on Nov 25, 2019

This example demonstrates a chart that responds to browser window resizing by redrawing an SVG to match the container’s current dimensions. On each resize event, the code reads the div’s `clientWidth` and `clientHeight` properties, then updates the SVG element’s `width` and `height` attributes via D3 v5 selections. It draws two intersecting green lines, forming an X, with thick semi-transparent strokes to visually confirm the resized coordinate system. The rendering approach uses D3’s data join with `enter()` and `merge()`, plus a CSS fixed-position container to fill the viewport.

AI-generated description
MIT Licensed

Similar vizzes