Skip to main content
100%

Responding to Resize

✓ Published0🌍 Public
TTheRedUnicorn
Last edited Jul 18, 2019
Created on Jul 18, 2019

This example demonstrates a chart that responds to browser resizing by redrawing its content to match the available space. It shows a large green X drawn across the entire viewport, with the SVG dimensions updating dynamically as the window changes. The code uses the D3 v5 library to bind an SVG element to a fixed-position container, then recalculates the width and height from the container's `clientWidth` and `clientHeight` properties on every resize event. A `redraw()` function defines two diagonal lines and updates their endpoints via D3's selection-merging API, while a window listener triggers the redraw.

AI-generated description
MIT Licensed

Similar vizzes