🌍 Public
Viewing a saved revision (read-only)
f1f3472894cc4a318ae90554b7f09de5
Responding to Resize
This example demonstrates a responsive SVG chart that continuously updates its dimensions to match the browser window. The visualization draws two diagonal green lines that form an X, with the lines' endpoints recalculated based on the current width and height. The code uses the `d3.select` method to append an SVG element to a fixed-position div, then reads the div’s `clientWidth` and `clientHeight` properties on every window resize event to update the SVG’s `width` and `height` attributes. The redraw function merges new line data with existing elements using D3’s `.merge` method.
AI-generated description