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

1
Kking-seo
Last edited Aug 28, 2019
Created on Aug 28, 2019

This example demonstrates how a D3.js visualization can respond dynamically to browser resizing. A green X-shaped pair of lines is drawn across the full viewport, with the SVG dimensions updated to match the CSS-computed container size on every resize event. The code uses `chartDiv.clientWidth` and `chartDiv.clientHeight` within a `redraw` function, triggered initially and via `window.addEventListener("resize", redraw)`. The SVG is created with `d3.select`, and lines are bound to data arrays and updated using the merge pattern.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed