Fork of Margins2
This example demonstrates the fundamental visualization layout pattern of defining margins to create an inner rectangle for chart content. A gray rectangle is drawn within the container, positioned according to specified top, right, bottom, and left margins, with its dimensions calculated by subtracting those margins from the container’s total width and height. The code uses a ResizeObserver to track container size changes and updates the state accordingly, then renders the rectangle with D3’s `select` and `join` methods. The visualization adapts responsively as the container resizes, showing how margins reserve space for axes and other chart elements.