Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Fork of Responding to Resize

Public visualization

Viewing a saved revision (read-only)

1ce43b9a7b084ff385cb67973e19fc7d

Fork of Responding to Resize

0 stars0🌍 Public
NNYCUBK201
Last edited Sep 18, 2023
Created on Sep 18, 2023

This example demonstrates how an SVG visualization can automatically resize to fill its container. It renders two green, semi-transparent lines forming an X that spans the full width and height of the available space. The code uses d3.v5 to select the chart div and append an SVG element, then a `redraw()` function extracts `clientWidth` and `clientHeight` from the container to update the SVG’s dimensions and line coordinates. A window `resize` event listener triggers this function, ensuring the visualization always matches the browser’s viewport size.

AI-generated description