Skip to content
EliteChart

niceTicks

Documentation


Documentation / @elitechart/core / niceTicks

code
function niceTicks(
   min, 
   max, 
   desiredCount): number[];

Defined in: math/ticks.ts:44

Compute axis tick positions for a value range.

Parameters

min

number

lower bound (inclusive)

max

number

upper bound (inclusive)

desiredCount

number

target number of ticks (actual may differ by 1–2)

Returns

number[]

sorted ascending array of tick values inside or equal to the bounds

Example

code
import { niceTicks } from '@elitechart/core';
niceTicks(0, 100, 5);     // [0, 25, 50, 75, 100]
niceTicks(67_320, 67_550, 6); // human-readable price ticks