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
Aantoinecarto
Last edited Jul 11, 2019
Created on Jul 11, 2019

This example shows a single SVG that dynamically redraws a large green X to fit the full browser window whenever the viewport changes. It uses plain JavaScript to listen for the window’s resize event, then reads the container’s clientWidth and clientHeight to update the SVG’s width and height attributes. A D3 v5 data join binds two line objects to render the diagonal strokes, merging enter and update selections to adjust coordinates. The chart fills the page via fixed CSS positioning, and no external data source is used.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed