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
Ssetom
Last edited Dec 12, 2019
Created on Dec 12, 2019

This example demonstrates a full-window SVG chart that automatically redraws itself whenever the browser window is resized. The code uses CSS fixed positioning to make a container div fill the viewport, then reads its `clientWidth` and `clientHeight` properties inside a `redraw()` function. It sets the SVG’s `width` and `height` attributes accordingly and renders two diagonal green lines forming an X, using the data-join pattern with `svg.selectAll("line").data()` and the `merge()` method. A global `resize` event listener triggers the redraw on every window size change.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed