Skip to main content
Public

Share visualization

Loading preview…

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

Responding to Resize

0
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

Comments

Sign in to join the discussion.

MIT Licensed