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
LLê Minh Bằng
Last edited Sep 6, 2024
Created on Sep 6, 2024

This example demonstrates a responsive SVG visualization that draws a diagonal green X across the full browser window. It uses D3 v5 to select the chart container and append an SVG element, then defines a `redraw` function that reads the container’s `clientWidth` and `clientHeight` via the CSS `getElementById` method. The function updates the SVG’s width and height attributes, binds two line data points, and applies stroke properties. A window `resize` event listener triggers `redraw` on every viewport change, ensuring the X always spans the current dimensions.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed