Skip to main content
100%

Responding to Resize

✓ Published0🌍 Public
Ggsonule
Last edited Sep 14, 2019
Created on Sep 14, 2019

This example shows how a visualization can adapt to browser window resizing by drawing a green X that spans the full width and height of the available space. The chart container uses CSS to fill the viewport, and a `resize` event listener triggers a `redraw` function that reads `chartDiv.clientWidth` and `clientHeight` to set the SVG’s dimensions. D3 v5’s data join (`selectAll`, `enter`, `merge`) updates the two line elements with new coordinates on every resize. The rendering uses SVG lines with a semi-transparent stroke.

AI-generated description
MIT Licensed

Similar vizzes