scaleLinearTicks
Generate nicely-spaced tick values for a linear scale domain using the Heckbert "nice numbers" algorithm.
scaleLinearTicks(domainMin: number, domainMax: number, count: number): number[]
domainMin — Lower bound of the domain.
domainMax — Upper bound of the domain.
count — Approximate number of ticks desired. The actual count may differ slightly to produce round values.
Returns — An array of nicely-spaced tick values within the domain. Tick values are rounded to clean multiples of 1, 2, 5, or powers of 10.
// Generate ~5 ticks for a domain of [0, 100]
const ticks = pathRite.scaleLinearTicks(0, 100, 5);
// ticks === [0, 20, 40, 60, 80, 100]
// Axis labels for an irregular domain
const labels = pathRite.scaleLinearTicks(0.13, 97.4, 5);
// labels === [0, 20, 40, 60, 80] (nice round values)