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
Jjonas.thomsen@campus.lmu.de
Last edited Nov 16, 2024
Created on Nov 16, 2024

This example demonstrates how a D3.js visualization can respond to browser resizing by redrawing an SVG element to fill the available screen space. It uses `d3.select` to append an SVG to a fixed-position div, then defines a `redraw` function that reads the container’s `clientWidth` and `clientHeight` to set the SVG’s dimensions. The visualization draws two diagonal lines forming a green X, with stroke opacity set via D3’s attribute and style methods. A `window.addEventListener("resize", redraw)` handler triggers the redraw on every viewport change.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed