Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Responding to Resize

0 stars0🌍 Public
LLittledevil7
Last edited Apr 15, 2020
Created on Apr 15, 2020

This example shows a bar chart of population by country that redraws its X-shaped guide lines whenever the browser window is resized. The code uses `clientWidth` and `clientHeight` to extract the computed CSS dimensions of the chart container, then sets the SVG’s `width` and `height` attributes accordingly. It employs a `window.addEventListener("resize", redraw)` to trigger the update. The bar chart itself is built with `d3.scaleLinear`, `d3.scaleBand`, `d3.axisLeft`, and `d3.axisBottom`, using population data loaded from a CSV file.

AI-generated description

Comments

Sign in to join the discussion.

MIT Licensed