Skip to main content
100%

Fork of Responsive Starter Code

✓ Published0🌍 Public
DDONAR144-release
Last edited Sep 18, 2022
Created on Sep 18, 2022

This example demonstrates a blank, responsive canvas that fills the entire browser window, showing a simple rounded rectangle that scales with the viewport. The visualization uses D3 v5 to bind data to SVG elements and update their dimensions on window resize. The core pattern involves D3’s data join method, `selection.merge()`, which reuses existing elements to apply new `width` and `height` attributes based on `document.body.clientWidth` and `clientHeight`. A `window.addEventListener('resize', render)` triggers the redraw, making the component fully responsive. The SVG rendering approach relies on a custom component function that takes container and props, illustrating a reusable template for building adaptive charts.

AI-generated description

Jumping off point for creating your own responsive visualizations.

MIT Licensed

Similar vizzes