Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Viewing a saved revision (read-only)

52324b21893d4cb28eff151266ffdd42

Responding to Resize

0 stars0🌍 Public
MMithun Ghosh
Last edited Nov 26, 2020
Created on Nov 26, 2020

This example demonstrates how an SVG visualization can respond to browser resizing by redrawing its content to fill the available viewport. It extracts the container’s client width and height, then uses those values to set the SVG element’s dimensions and draw two diagonal lines forming an X shape. The code uses d3.select to append the SVG, d3’s data join with merge to update existing line elements, and a window resize event listener that triggers the redraw function. The green, semi-transparent strokes scale proportionally with the window.

AI-generated description