Skip to main content
100%

Density-based Ticks

✓ Published0🌍 Public
CCurran Kelleher
Last edited Jan 24, 2017
Created on Sep 2, 2015

This example demonstrates how to set tick marks to a fixed pixel density, so the number of ticks adapts to the chart's changing width. The code uses d3.axisBottom and d3.scaleLinear, with the tick count computed as varyingWidth divided by a constant xPixelsPerTick. A sinusoidal animation continuously adjusts the inner width, and requestAnimationFrame re-renders the axis in an SVG. The visualization shows the axis label and tick marks updating in real time, illustrating a responsive approach for resizable charts.

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.

Derived from

<!-- Start of SimpleHitCounter Code --> <div align="center"><a href="http://www.simplehitcounter.com" target="_blank"><img src="http://simplehitcounter.com/hit.php?uid=1948666&f=16777215&b=0" border="0" height="18" width="83" alt="web counter"></a></div> <!-- End of SimpleHitCounter Code -->
mit Licensed

Similar vizzes