Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Responding to Resize

Public visualization

Viewing a saved revision (read-only)

4856fe570b654f3994dfee3e5d31644b

Responding to Resize

0 stars0🌍 Public
Ddbidwai
Last edited Nov 22, 2020
Created on Nov 22, 2020

This example demonstrates how a D3.js visualization can dynamically adjust to fit its container. It draws a large green X composed of two diagonal lines that stretch from corner to corner, with the SVG element’s width and height updated to match the chart div’s client dimensions. The code uses `d3.select` and `selection.attr` to resize the SVG, and a `window.addEventListener("resize", redraw)` function to trigger the redraw. The rendering approach is SVG, with the chart container styled via CSS to fill the entire viewport.

AI-generated description