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
Hhamza.miftah@gmail.com
Last edited Jul 10, 2022
Created on Jul 10, 2022

This example demonstrates a responsive SVG visualization that fills the entire browser window and redraws its content whenever the viewport size changes. It shows two thick, semi-transparent green lines forming an X across the full width and height of the chart container. The code uses D3 v5 to select the `#chart` div, append an SVG element, and bind line data to render the X. A `redraw` function reads the container’s `clientWidth` and `clientHeight` to update the SVG’s dimensions, then repositions the lines via the `merge` pattern. The `window.addEventListener("resize", redraw)` triggers this responsive behavior.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed