Skip to main content
100%

Responsive Starter Code

✓ Published0🌍 Public
PParamjeet Dhiman
Last edited Jan 20, 2020
Created on Jan 20, 2020

This example demonstrates a minimal responsive visualization template. It shows a single rounded rectangle that always fills the browser window, with its dimensions recalculated on every resize event. The code defines a reusable `myResponsiveComponent` function that takes a container and size properties, then creates or updates an SVG element and its `rect` child using D3 v5’s data-join pattern (`selectAll().data([null])`). It uses `document.body.clientWidth` and `clientHeight` as the size source, and re-renders by attaching a `resize` event listener to the window.

AI-generated description

Jumping off point for creating your own responsive visualizations.

MIT Licensed

Similar vizzes