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
Ddok0086m
Last edited Dec 20, 2022
Created on Dec 20, 2022

This example demonstrates a responsive SVG visualization that fills the entire browser window and redraws its content whenever the viewport size changes. The page uses CSS to stretch a chart container to full screen, then d3.js extracts the container’s clientWidth and clientHeight on each resize event to update the SVG’s width and height attributes. Two diagonal lines form a green X marker whose endpoints adjust to the current dimensions, showcasing how to bind data containing the new coordinates and re-render with a selection merge. The code relies on d3.select, selection.attr, and window.addEventListener for the resize handling.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed