Skip to main content
100%

Responsive Axes with value labels

✓ Published0🌍 Public
MMaarten Snels
Last edited Feb 10, 2024
Created on Feb 10, 2024
Forked from Responsive Axes

This example demonstrates responsive axes that maintain a consistent tick mark density as the visualization is resized. It shows a line chart with labeled X and Y axes inside a grey plotting area, where the number of ticks adjusts dynamically to the chart's dimensions. The code uses D3’s `scaleLinear`, `axisBottom`, and `axisLeft` functions, along with a `ResizeObserver` to track container size changes. Tick count is calculated by dividing the inner axis length by a fixed density value (50 pixels), ensuring readable spacing across varied widths and heights.

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
MIT Licensed

Similar vizzes