Skip to main content
Public

Share visualization

Loading preview…

Fork of Margins2

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Fork of Margins2

0
AAzhar Harisandi
Last edited Dec 26, 2024
Created on Dec 26, 2024
Forked from Margins

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.

AI-generated description

We define the "inner rectangle" for our visualizations using margins! These are important for

  • Defining where the marks go for our data visualizations
  • Giving space for the axes

Comments

Sign in to join the discussion.

MIT Licensed