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
Ppradeep90605
Last edited Jun 21, 2020
Created on Jun 21, 2020

This example demonstrates a responsive SVG visualization that redraws itself to match the browser window’s dimensions. The chart fills the entire viewport via CSS, and a `redraw()` function extracts the container’s `clientWidth` and `clientHeight` to set the SVG’s width and height attributes. It then draws a green semi-transparent X composed of two diagonal lines, using D3’s data binding and merge operators to update the line positions. The code relies on D3 v5’s selection API and listens for window resize events to trigger the redraw, ensuring the graphic always spans the available space.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed