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
AAnton Bodnya
Last edited Jul 16, 2019
Created on Jul 16, 2019

This example demonstrates a responsive D3.js visualization that adapts automatically when the browser window is resized. It shows a large green X drawn across an SVG canvas that fills the entire viewport. The code uses the `clientWidth` and `clientHeight` properties of the chart container to measure the CSS-computed dimensions, then applies those values to the SVG via `attr("width")` and `attr("height")`. A `redraw` function, triggered by a `resize` event listener, re-renders the X marks to match the updated size.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed