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
GGuan
Last edited Sep 13, 2024
Created on Sep 13, 2024

This example shows an SVG that dynamically resizes to fill the browser window, drawing a green X that spans the full width and height. The code uses a fixed-position `#chart` div and reads its `clientWidth` and `clientHeight` to set the SVG’s attributes on every resize. It leverages d3.v5’s data join with `selectAll`, `enter`, and `merge` to update two `line` elements, and listens to the window’s `resize` event to trigger a redraw. The rendering is purely SVG with no external data source.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed