Responding to Resize
✓ Published0🌍 Public
This example demonstrates how a visualization can adapt to browser resizing. The code uses CSS to make a chart container fill the viewport and JavaScript to extract its `clientWidth` and `clientHeight` on every resize event. It redraws an SVG element with `d3.select` and `svg.attr` to match the new dimensions, then renders two intersecting green lines to form an X. The D3 v5 code uses `.selectAll("line")`, `.data()`, `.enter()`, and `.merge()` to update the line elements, which visually confirms the chart’s size synchronization.
AI-generated descriptionMIT Licensed