Skip to main content
100%

Responsive Starter Code

✓ Published5🌍 Public
CCurran Kelleher
Last edited Jun 24, 2019
Created on Jun 24, 2019

This example demonstrates a minimal responsive SVG setup using D3 v5. The code creates a single filled rectangle that always fills the browser viewport by reading `document.body.clientWidth` and `document.body.clientHeight`. A custom `myResponsiveComponent` function binds data to an SVG element and appends a rounded rectangle, updating its `width` and `height` attributes on every window resize event. The D3 selection pattern with `.enter().append().merge()` ensures the existing elements are updated efficiently.

AI-generated description

Jumping off point for creating your own responsive visualizations.

MIT Licensed

Similar vizzes