Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Viewing a saved revision (read-only)

5f7b6f6f077f48459681ff63855bfd4e

Responding to Resize

0 stars1🌍 Public
MManikyapavan
Last edited Jun 2, 2020
Created on Jun 2, 2020

This example demonstrates how a D3.js visualization can respond to browser resizing by redrawing its content to match the new dimensions. The page uses a CSS-styled container and a redraw function that reads `clientWidth` and `clientHeight` to set the SVG’s `width` and `height` attributes. It draws two green lines forming an X across the full viewport, with strokes updated on each resize event. The code uses D3 v5 with `d3.select`, `svg.attr`, and `window.addEventListener` to handle the dynamic resizing.

AI-generated description