MCPcopy
hub / github.com/chartjs/Chart.js / determineUnitForAutoTicks

Function determineUnitForAutoTicks

src/scales/scale.time.js:87–100  ·  view source on GitHub ↗

* Figures out what unit results in an appropriate number of auto-generated ticks * @param {Unit} minUnit * @param {number} min * @param {number} max * @param {number} capacity * @return {object}

(minUnit, min, max, capacity)

Source from the content-addressed store, hash-verified

85 * @return {object}
86 */
87function determineUnitForAutoTicks(minUnit, min, max, capacity) {
88 const ilen = UNITS.length;
89
90 for (let i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) {
91 const interval = INTERVALS[UNITS[i]];
92 const factor = interval.steps ? interval.steps : Number.MAX_SAFE_INTEGER;
93
94 if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) {
95 return UNITS[i];
96 }
97 }
98
99 return UNITS[ilen - 1];
100}
101
102/**
103 * Figures out what unit to format a set of ticks with

Callers 2

buildTicksMethod · 0.85
_generateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected