pow.js 737 B

123456789101112131415161718192021
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var math_1 = require("../util/math");
  4. var pretty_1 = require("../util/pretty");
  5. /**
  6. * 计算 Pow 的 ticks
  7. * @param cfg 度量的配置项
  8. * @returns 计算后的 ticks
  9. */
  10. function calculatePowTicks(cfg) {
  11. var exponent = cfg.exponent, tickCount = cfg.tickCount;
  12. var max = Math.ceil(math_1.calBase(exponent, cfg.max));
  13. var min = Math.floor(math_1.calBase(exponent, cfg.min));
  14. var ticks = pretty_1.default(min, max, tickCount).ticks;
  15. return ticks.map(function (tick) {
  16. var factor = tick >= 0 ? 1 : -1;
  17. return Math.pow(tick, exponent) * factor;
  18. });
  19. }
  20. exports.default = calculatePowTicks;
  21. //# sourceMappingURL=pow.js.map