Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Fork of Responding to Resize

Public visualization

Fork of Responding to Resize

0 stars0🌍 Public
Ssyedkabir268
Last edited Dec 26, 2020
Created on Dec 26, 2020

This example demonstrates how a D3.js visualization can respond dynamically to browser window resizing. It draws a large green X shape using two SVG line elements that stretch to fill the entire viewport, with the chart container styled via CSS to occupy the full page. On every resize event, a `redraw()` function reads the container’s `clientWidth` and `clientHeight`, updates the SVG’s width and height attributes, and repositions the lines using the data-join pattern with `selectAll` and `merge`. The code relies on D3 v5 and the native browser `window.addEventListener` for resize handling.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed