UNPKG

611 BJavaScriptView Raw
1import { calBase } from '../util/math';
2import pretty from '../util/pretty';
3/**
4 * 计算 Pow 的 ticks
5 * @param cfg 度量的配置项
6 * @returns 计算后的 ticks
7 */
8export default function calculatePowTicks(cfg) {
9 var exponent = cfg.exponent, tickCount = cfg.tickCount;
10 var max = Math.ceil(calBase(exponent, cfg.max));
11 var min = Math.floor(calBase(exponent, cfg.min));
12 var ticks = pretty(min, max, tickCount).ticks;
13 return ticks.map(function (tick) {
14 var factor = tick >= 0 ? 1 : -1;
15 return Math.pow(tick, exponent) * factor;
16 });
17}
18//# sourceMappingURL=pow.js.map
\No newline at end of file