Skip to main content
100%

Density-based Ticks

✓ Published0🌍 Public
CCurran Kelleher
Last edited Jun 19, 2020
Created on Jun 19, 2020
Forked from HTML Starter

The example animates a resizable axis whose tick count adjusts dynamically to maintain a constant pixel density between ticks. As the axis width oscillates with a sine wave, the tick frequency updates accordingly. The visualization uses D3 v5's `d3.axisBottom` and `d3.scaleLinear`, with tick density controlled by dividing the current width by a fixed pixels-per-tick threshold. SVG rendering and `requestAnimationFrame` drive the smooth animation loop.

AI-generated description

This example shows how you can set up tick marks to be a fixed density rather than a fixed number of tick marks. This is useful for implementing visualizations that can be resized by the user.

MIT Licensed

Similar vizzes