Skip to main content
100%

Fork of Responding to Resize

✓ Published0🌍 Public
DDaniel
Last edited Jun 4, 2021
Created on Jun 4, 2021

This example demonstrates how a D3.js visualization can automatically resize its SVG output to match the browser window’s dimensions. The code uses CSS to make a container div fill the viewport, then reads `clientWidth` and `clientHeight` to set the SVG’s width and height attributes. It draws an X shape using two green lines with heavy stroke width and opacity, showing the current size. The `redraw` function reapplies these dimensions whenever the window is resized by listening to the `resize` event.

AI-generated description
MIT Licensed

Similar vizzes