Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Viewing a saved revision (read-only)

1ab7e3b1e28749dd95734197935b2eee

Responding to Resize

0 stars0🌍 Public
Ss-janibekova
Last edited Oct 25, 2019
Created on Oct 25, 2019

This example demonstrates a chart that responds to browser resizing by redrawing its content to match the new window dimensions. It uses a fixed-position div and extracts its client width and height to set the SVG size. The visualization draws two green, semi-transparent lines forming an X across the plot area, with stroke width set to 100. The redraw function is triggered on the window’s resize event. The code relies on d3.select to append an SVG and d3’s selection methods (`selectAll`, `enter`, `merge`, and `attr`) to update line coordinates.

AI-generated description