Skip to main content
100%

Responsive Margin Convention

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

This example shows a reusable pattern for building responsive visualizations that maintain consistent margins as the window resizes. It uses the `d3` library (v5) to render an SVG with a rounded rectangle that fills the available space within the specified margin. The `marginConvention` function translates a group element to the margin offset and calculates the inner dimensions, while the `index.js` file re-renders on window resize. The code demonstrates the classic D3 margin convention, using `d3.select` and SVG attributes like `width`, `height`, and `transform`.

AI-generated description

Jumping off point for creating your own responsive visualizations with margins.

Contains a reusable implementation of the D3.js Margin Convention.

MIT Licensed

Similar vizzes