Skip to main content
Public

Share visualization

Loading preview…

Fork of Responding to Resize

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Fork of Responding to Resize

0
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