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
Ttranviet191999
Last edited May 26, 2021
Created on May 26, 2021

This example demonstrates a minimal responsive SVG visualization that adapts to the browser window’s dimensions. It shows a single thick red diagonal line spanning the entire viewport. The code uses the D3.js v5 library to select a container div, append an SVG element, and redraw upon window resizing. It extracts the CSS-computed `clientWidth` and `clientHeight` to set the SVG’s width and height attributes, then draws the line using the `line` element with hardcoded coordinates. The redraw function is triggered manually once and then on each window resize event.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed