🌍 Public
Viewing a saved revision (read-only)
74d753b41219442c8f67ba0f6517c649
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