Responding to Resize
✓ Published0🌍 Public
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 descriptionMIT Licensed