Viz Function concept
✓ Published0🌍 Public
This example demonstrates the fundamental concept of margins in data visualization by drawing a gray rectangle that sits inside a larger white canvas, with padding on all four sides. The code uses D3.js (version 7.8.5) and its `select` API to create an SVG element, then renders the rectangle with computed dimensions based on the container’s client width and height minus fixed top, left, bottom, and right margins. The inner rectangle’s size is calculated from those margin values, and a fill color of `#808080` distinguishes it from the surrounding space.
AI-generated descriptionD3 Margins
MIT Licensed