Skip to main content
Public

Share visualization

Loading preview…

Responsive Axes

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

Responsive Axes

17
CCurran Kelleher
Last edited Feb 12, 2024
Created on Feb 7, 2024
Forked from Axis Labels

This example demonstrates a visualization container with responsive axes that maintain consistent tick mark density as the chart resizes. The code uses a ResizeObserver to track container dimensions and updates a D3 v7 scatterplot-like visualization with a gray inner rectangle. Both the x and y axes compute their tick counts dynamically based on the available inner width and height, dividing by a fixed density value of 50 pixels per tick. This approach ensures the axis labels remain evenly spaced whether the viewport is large or small.

AI-generated description

A viz container with responsive axes that have consistent tick mark density. Try opening in full screen mode and resizing!

Challenge

  • Use this technique to make the axes on your viz responsive

Comments

Sign in to join the discussion.

MIT Licensed