recharts-scale
Advanced tools
Comparing version 0.3.2 to 0.4.0
@@ -14,2 +14,7 @@ 'use strict'; | ||
var _decimal = require('decimal.js-light'); | ||
var _decimal2 = _interopRequireDefault(_decimal); | ||
var _utils = require('./util/utils'); | ||
@@ -53,23 +58,25 @@ | ||
* | ||
* @param {Number} roughStep The rough step calculated by deviding the | ||
* @param {Decimal} roughStep The rough step calculated by deviding the | ||
* difference by the tickCount | ||
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not | ||
* @param {Integer} correctionFactor A correction factor | ||
* @return {Number} The step which is easy to understand between two ticks | ||
* @return {Decimal} The step which is easy to understand between two ticks | ||
*/ | ||
function getFormatStep(roughStep, allowDecimals, correctionFactor) { | ||
if (roughStep <= 0) { | ||
return 0; | ||
if (roughStep.lte(0)) { | ||
return new _decimal2.default(0); | ||
} | ||
var digitCount = _arithmetic2.default.getDigitCount(roughStep); | ||
var digitCount = _arithmetic2.default.getDigitCount(roughStep.toNumber()); | ||
// The ratio between the rough step and the smallest number which has a bigger | ||
// order of magnitudes than the rough step | ||
var stepRatio = roughStep / Math.pow(10, digitCount); | ||
var digitCountValue = new _decimal2.default(10).pow(digitCount); | ||
var stepRatio = roughStep.div(digitCountValue); | ||
// When an integer and a float multiplied, the accuracy of result may be wrong | ||
var amendStepRatio = digitCount !== 1 ? _arithmetic2.default.multiply(Math.ceil(stepRatio / 0.05) + correctionFactor, 0.05) : _arithmetic2.default.multiply(Math.ceil(stepRatio / 0.1) + correctionFactor, 0.1); | ||
var stepRatioScale = digitCount !== 1 ? 0.05 : 0.1; | ||
var amendStepRatio = new _decimal2.default(Math.ceil(stepRatio.div(stepRatioScale).toNumber())).add(correctionFactor).mul(stepRatioScale); | ||
var formatStep = _arithmetic2.default.multiply(amendStepRatio, Math.pow(10, digitCount)); | ||
var formatStep = amendStepRatio.mul(digitCountValue); | ||
return allowDecimals ? formatStep : Math.ceil(formatStep); | ||
return allowDecimals ? formatStep : new _decimal2.default(Math.ceil(formatStep)); | ||
} | ||
@@ -86,8 +93,7 @@ | ||
function getTickOfSingleValue(value, tickCount, allowDecimals) { | ||
var isFlt = _arithmetic2.default.isFloat(value); | ||
var step = 1; | ||
// calculate the middle value of ticks | ||
var middle = value; | ||
var middle = new _decimal2.default(value); | ||
if (isFlt && allowDecimals) { | ||
if (!middle.isint() && allowDecimals) { | ||
var absVal = Math.abs(value); | ||
@@ -97,13 +103,13 @@ | ||
// The step should be a float number when the difference is smaller than 1 | ||
step = Math.pow(10, _arithmetic2.default.getDigitCount(value) - 1); | ||
step = new _decimal2.default(10).pow(_arithmetic2.default.getDigitCount(value) - 1); | ||
middle = _arithmetic2.default.multiply(Math.floor(value / step), step); | ||
middle = new _decimal2.default(Math.floor(middle.div(step).toNumber())).mul(step); | ||
} else if (absVal > 1) { | ||
// Return the maximum integer which is smaller than 'value' when 'value' is greater than 1 | ||
middle = Math.floor(value); | ||
middle = new _decimal2.default(Math.floor(value)); | ||
} | ||
} else if (value === 0) { | ||
middle = Math.floor((tickCount - 1) / 2); | ||
middle = new _decimal2.default(Math.floor((tickCount - 1) / 2)); | ||
} else if (!allowDecimals) { | ||
middle = Math.floor(value); | ||
middle = new _decimal2.default(Math.floor(value)); | ||
} | ||
@@ -114,3 +120,3 @@ | ||
var fn = (0, _utils.compose)((0, _utils.map)(function (n) { | ||
return _arithmetic2.default.sum(middle, _arithmetic2.default.multiply(n - middleIndex, step)); | ||
return middle.add(new _decimal2.default(n - middleIndex).mul(step)).toNumber(); | ||
}), _utils.range); | ||
@@ -134,4 +140,13 @@ | ||
// dirty hack (for recharts' test) | ||
if (!Number.isFinite((max - min) / (tickCount - 1))) { | ||
return { | ||
step: new _decimal2.default(0), | ||
tickMin: new _decimal2.default(0), | ||
tickMax: new _decimal2.default(0) | ||
}; | ||
} | ||
// The step which is easy to understand between two ticks | ||
var step = getFormatStep((max - min) / (tickCount - 1), allowDecimals, correctionFactor); | ||
var step = getFormatStep(new _decimal2.default(max).sub(min).div(tickCount - 1), allowDecimals, correctionFactor); | ||
@@ -143,14 +158,12 @@ // A medial value of ticks | ||
if (min <= 0 && max >= 0) { | ||
middle = 0; | ||
middle = new _decimal2.default(0); | ||
} else { | ||
// calculate the middle value | ||
middle = _arithmetic2.default.divide(_arithmetic2.default.sum(min, max), 2); | ||
middle = new _decimal2.default(min).add(max).div(2); | ||
// minus modulo value | ||
middle = _arithmetic2.default.minus(middle, _arithmetic2.default.modulo(middle, step)); | ||
// strip | ||
middle = _arithmetic2.default.strip(middle, 16); | ||
middle = middle.sub(new _decimal2.default(middle).mod(step)); | ||
} | ||
var belowCount = Math.ceil((middle - min) / step); | ||
var upCount = Math.ceil((max - middle) / step); | ||
var belowCount = Math.ceil(middle.sub(min).div(step).toNumber()); | ||
var upCount = Math.ceil(new _decimal2.default(max).sub(middle).div(step).toNumber()); | ||
var scaleCount = belowCount + upCount + 1; | ||
@@ -169,4 +182,4 @@ | ||
step: step, | ||
tickMin: _arithmetic2.default.minus(middle, _arithmetic2.default.multiply(belowCount, step)), | ||
tickMax: _arithmetic2.default.sum(middle, _arithmetic2.default.multiply(upCount, step)) | ||
tickMin: middle.sub(new _decimal2.default(belowCount).mul(step)), | ||
tickMax: middle.add(new _decimal2.default(upCount).mul(step)) | ||
}; | ||
@@ -209,3 +222,3 @@ } | ||
var values = _arithmetic2.default.rangeStep(tickMin, tickMax + 0.1 * step, step); | ||
var values = _arithmetic2.default.rangeStep(tickMin, tickMax.add(new _decimal2.default(0.1).mul(step)), step); | ||
@@ -235,6 +248,6 @@ return min > max ? (0, _utils.reverse)(values) : values; | ||
var step = getFormatStep((cormax - cormin) / (count - 1), allowDecimals, 0); | ||
var step = getFormatStep(new _decimal2.default(cormax).sub(cormin).div(count - 1), allowDecimals, 0); | ||
var fn = (0, _utils.compose)((0, _utils.map)(function (n) { | ||
return cormin + n * step; | ||
return new _decimal2.default(cormin).add(new _decimal2.default(n).mul(step)).toNumber(); | ||
}), _utils.range); | ||
@@ -267,4 +280,4 @@ | ||
var count = Math.max(tickCount, 2); | ||
var step = getFormatStep((cormax - cormin) / (count - 1), allowDecimals, 0); | ||
var values = [].concat(_toConsumableArray(_arithmetic2.default.rangeStep(cormin, cormax - 0.99 * step, step)), [cormax]); | ||
var step = getFormatStep(new _decimal2.default(cormax).sub(cormin).div(count - 1), allowDecimals, 0); | ||
var values = [].concat(_toConsumableArray(_arithmetic2.default.rangeStep(new _decimal2.default(cormin), new _decimal2.default(cormax).sub(new _decimal2.default(0.99).mul(step)), step)), [cormax]); | ||
@@ -271,0 +284,0 @@ return min > max ? (0, _utils.reverse)(values) : values; |
@@ -7,32 +7,9 @@ 'use strict'; | ||
var _utils = require('./utils'); | ||
var _decimal = require('decimal.js-light'); | ||
/** | ||
* 把错误的数据转正 | ||
* strip(0.09999999999999998)=0.1 | ||
* @param {Number} num 输入值 | ||
* @param {Number} precision 精度 | ||
* @return {Number} 数值 | ||
*/ | ||
function strip(num) { | ||
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 12; | ||
var _decimal2 = _interopRequireDefault(_decimal); | ||
return +parseFloat(num.toPrecision(precision)); | ||
} | ||
var _utils = require('./utils'); | ||
/** | ||
* 判断数据是否为浮点类型 | ||
* | ||
* @param {Number} num 输入值 | ||
* @return {Boolean} 是否是浮点类型 | ||
*/ | ||
/** | ||
* @fileOverview 一些公用的运算方法 | ||
* @author xile611 | ||
* @date 2015-09-17 | ||
*/ | ||
function isFloat(num) { | ||
return (/^([+-]?)\d*\.\d+$/.test(num) | ||
); | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -48,4 +25,8 @@ /** | ||
*/ | ||
/** | ||
* @fileOverview 一些公用的运算方法 | ||
* @author xile611 | ||
* @date 2015-09-17 | ||
*/ | ||
function getDigitCount(value) { | ||
var abs = Math.abs(value); | ||
var result = void 0; | ||
@@ -56,3 +37,3 @@ | ||
} else { | ||
result = Math.floor(Math.log(abs) / Math.log(10)) + 1; | ||
result = Math.floor(new _decimal2.default(value).abs().log(10).toNumber()) + 1; | ||
} | ||
@@ -62,96 +43,20 @@ | ||
} | ||
/** | ||
* 计算数值的小数点后的位数 | ||
* @param {Number} a 数值,可能为整数,也可能为浮点数 | ||
* @return {Integer} 位数 | ||
*/ | ||
function getDecimalDigitCount(a) { | ||
var str = a ? '' + a : ''; | ||
// scientific notation | ||
if (str.indexOf('e') >= 0) { | ||
return Math.abs(parseInt(str.slice(str.indexOf('e') + 1), 10)); | ||
} | ||
var ary = str.split('.'); | ||
return ary.length > 1 ? ary[1].length : 0; | ||
} | ||
/** | ||
* 乘法运算,解决了js运算的精度问题 | ||
* @param {Number} a 被乘数 | ||
* @param {Number} b 乘数 | ||
* @return {Number} 积 | ||
*/ | ||
function multiply(a, b) { | ||
var intA = parseInt(('' + a).replace('.', ''), 10); | ||
var intB = parseInt(('' + b).replace('.', ''), 10); | ||
var count = getDecimalDigitCount(a) + getDecimalDigitCount(b); | ||
return intA * intB / Math.pow(10, count); | ||
} | ||
/** | ||
* 加法运算,解决了js运算的精度问题 | ||
* @param {Number} a 被加数 | ||
* @param {Number} b 加数 | ||
* @return {Number} 和 | ||
*/ | ||
function sum(a, b) { | ||
var count = Math.max(getDecimalDigitCount(a), getDecimalDigitCount(b)); | ||
count = Math.pow(10, count); | ||
return (multiply(a, count) + multiply(b, count)) / count; | ||
} | ||
/** | ||
* 减法运算,解决了js运算的精度问题 | ||
* @param {Number} a 被减数 | ||
* @param {Number} b 减数 | ||
* @return {Number} 差 | ||
*/ | ||
function minus(a, b) { | ||
return sum(a, -b); | ||
} | ||
/** | ||
* 除法运算,解决了js运算的精度问题 | ||
* @param {Number} a 被除数 | ||
* @param {Number} b 除数 | ||
* @return {Number} 结果 | ||
*/ | ||
function divide(a, b) { | ||
var ca = getDecimalDigitCount(a); | ||
var cb = getDecimalDigitCount(b); | ||
var intA = parseInt(('' + a).replace('.', ''), 10); | ||
var intB = parseInt(('' + b).replace('.', ''), 10); | ||
return intA / intB * Math.pow(10, cb - ca); | ||
} | ||
function modulo(a, b) { | ||
var mod = Math.abs(b); | ||
if (b <= 0) { | ||
return a; | ||
} | ||
var cnt = Math.floor(a / mod); | ||
return minus(a, multiply(mod, cnt)); | ||
} | ||
/** | ||
* 按照固定的步长获取[start, end)这个区间的数据 | ||
* 并且需要处理js计算精度的问题 | ||
* | ||
* @param {Number} start 起点 | ||
* @param {Number} end 终点,不包含该值 | ||
* @param {Number} step 步长 | ||
* @return {Array} 若干数值 | ||
* @param {Decimal} start 起点 | ||
* @param {Decimal} end 终点,不包含该值 | ||
* @param {Decimal} step 步长 | ||
* @return {Array} 若干数值 | ||
*/ | ||
function rangeStep(start, end, step) { | ||
var num = start; | ||
var num = new _decimal2.default(start); | ||
var result = []; | ||
while (num < end) { | ||
result.push(num); | ||
while (num.lt(end)) { | ||
result.push(num.toNumber()); | ||
num = sum(num, step); | ||
num = num.add(step); | ||
} | ||
@@ -209,13 +114,4 @@ | ||
rangeStep: rangeStep, | ||
isFloat: isFloat, | ||
getDigitCount: getDigitCount, | ||
getDecimalDigitCount: getDecimalDigitCount, | ||
sum: sum, | ||
minus: minus, | ||
multiply: multiply, | ||
divide: divide, | ||
modulo: modulo, | ||
strip: strip, | ||
interpolateNumber: interpolateNumber, | ||
@@ -222,0 +118,0 @@ uninterpolateNumber: uninterpolateNumber, |
@@ -14,2 +14,7 @@ 'use strict'; | ||
var _decimal = require('decimal.js-light'); | ||
var _decimal2 = _interopRequireDefault(_decimal); | ||
var _utils = require('./util/utils'); | ||
@@ -53,23 +58,25 @@ | ||
* | ||
* @param {Number} roughStep The rough step calculated by deviding the | ||
* @param {Decimal} roughStep The rough step calculated by deviding the | ||
* difference by the tickCount | ||
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not | ||
* @param {Integer} correctionFactor A correction factor | ||
* @return {Number} The step which is easy to understand between two ticks | ||
* @return {Decimal} The step which is easy to understand between two ticks | ||
*/ | ||
function getFormatStep(roughStep, allowDecimals, correctionFactor) { | ||
if (roughStep <= 0) { | ||
return 0; | ||
if (roughStep.lte(0)) { | ||
return new _decimal2.default(0); | ||
} | ||
var digitCount = _arithmetic2.default.getDigitCount(roughStep); | ||
var digitCount = _arithmetic2.default.getDigitCount(roughStep.toNumber()); | ||
// The ratio between the rough step and the smallest number which has a bigger | ||
// order of magnitudes than the rough step | ||
var stepRatio = roughStep / Math.pow(10, digitCount); | ||
var digitCountValue = new _decimal2.default(10).pow(digitCount); | ||
var stepRatio = roughStep.div(digitCountValue); | ||
// When an integer and a float multiplied, the accuracy of result may be wrong | ||
var amendStepRatio = digitCount !== 1 ? _arithmetic2.default.multiply(Math.ceil(stepRatio / 0.05) + correctionFactor, 0.05) : _arithmetic2.default.multiply(Math.ceil(stepRatio / 0.1) + correctionFactor, 0.1); | ||
var stepRatioScale = digitCount !== 1 ? 0.05 : 0.1; | ||
var amendStepRatio = new _decimal2.default(Math.ceil(stepRatio.div(stepRatioScale).toNumber())).add(correctionFactor).mul(stepRatioScale); | ||
var formatStep = _arithmetic2.default.multiply(amendStepRatio, Math.pow(10, digitCount)); | ||
var formatStep = amendStepRatio.mul(digitCountValue); | ||
return allowDecimals ? formatStep : Math.ceil(formatStep); | ||
return allowDecimals ? formatStep : new _decimal2.default(Math.ceil(formatStep)); | ||
} | ||
@@ -86,8 +93,7 @@ | ||
function getTickOfSingleValue(value, tickCount, allowDecimals) { | ||
var isFlt = _arithmetic2.default.isFloat(value); | ||
var step = 1; | ||
// calculate the middle value of ticks | ||
var middle = value; | ||
var middle = new _decimal2.default(value); | ||
if (isFlt && allowDecimals) { | ||
if (!middle.isint() && allowDecimals) { | ||
var absVal = Math.abs(value); | ||
@@ -97,13 +103,13 @@ | ||
// The step should be a float number when the difference is smaller than 1 | ||
step = Math.pow(10, _arithmetic2.default.getDigitCount(value) - 1); | ||
step = new _decimal2.default(10).pow(_arithmetic2.default.getDigitCount(value) - 1); | ||
middle = _arithmetic2.default.multiply(Math.floor(value / step), step); | ||
middle = new _decimal2.default(Math.floor(middle.div(step).toNumber())).mul(step); | ||
} else if (absVal > 1) { | ||
// Return the maximum integer which is smaller than 'value' when 'value' is greater than 1 | ||
middle = Math.floor(value); | ||
middle = new _decimal2.default(Math.floor(value)); | ||
} | ||
} else if (value === 0) { | ||
middle = Math.floor((tickCount - 1) / 2); | ||
middle = new _decimal2.default(Math.floor((tickCount - 1) / 2)); | ||
} else if (!allowDecimals) { | ||
middle = Math.floor(value); | ||
middle = new _decimal2.default(Math.floor(value)); | ||
} | ||
@@ -114,3 +120,3 @@ | ||
var fn = (0, _utils.compose)((0, _utils.map)(function (n) { | ||
return _arithmetic2.default.sum(middle, _arithmetic2.default.multiply(n - middleIndex, step)); | ||
return middle.add(new _decimal2.default(n - middleIndex).mul(step)).toNumber(); | ||
}), _utils.range); | ||
@@ -134,4 +140,13 @@ | ||
// dirty hack (for recharts' test) | ||
if (!Number.isFinite((max - min) / (tickCount - 1))) { | ||
return { | ||
step: new _decimal2.default(0), | ||
tickMin: new _decimal2.default(0), | ||
tickMax: new _decimal2.default(0) | ||
}; | ||
} | ||
// The step which is easy to understand between two ticks | ||
var step = getFormatStep((max - min) / (tickCount - 1), allowDecimals, correctionFactor); | ||
var step = getFormatStep(new _decimal2.default(max).sub(min).div(tickCount - 1), allowDecimals, correctionFactor); | ||
@@ -143,14 +158,12 @@ // A medial value of ticks | ||
if (min <= 0 && max >= 0) { | ||
middle = 0; | ||
middle = new _decimal2.default(0); | ||
} else { | ||
// calculate the middle value | ||
middle = _arithmetic2.default.divide(_arithmetic2.default.sum(min, max), 2); | ||
middle = new _decimal2.default(min).add(max).div(2); | ||
// minus modulo value | ||
middle = _arithmetic2.default.minus(middle, _arithmetic2.default.modulo(middle, step)); | ||
// strip | ||
middle = _arithmetic2.default.strip(middle, 16); | ||
middle = middle.sub(new _decimal2.default(middle).mod(step)); | ||
} | ||
var belowCount = Math.ceil((middle - min) / step); | ||
var upCount = Math.ceil((max - middle) / step); | ||
var belowCount = Math.ceil(middle.sub(min).div(step).toNumber()); | ||
var upCount = Math.ceil(new _decimal2.default(max).sub(middle).div(step).toNumber()); | ||
var scaleCount = belowCount + upCount + 1; | ||
@@ -169,4 +182,4 @@ | ||
step: step, | ||
tickMin: _arithmetic2.default.minus(middle, _arithmetic2.default.multiply(belowCount, step)), | ||
tickMax: _arithmetic2.default.sum(middle, _arithmetic2.default.multiply(upCount, step)) | ||
tickMin: middle.sub(new _decimal2.default(belowCount).mul(step)), | ||
tickMax: middle.add(new _decimal2.default(upCount).mul(step)) | ||
}; | ||
@@ -209,3 +222,3 @@ } | ||
var values = _arithmetic2.default.rangeStep(tickMin, tickMax + 0.1 * step, step); | ||
var values = _arithmetic2.default.rangeStep(tickMin, tickMax.add(new _decimal2.default(0.1).mul(step)), step); | ||
@@ -235,6 +248,6 @@ return min > max ? (0, _utils.reverse)(values) : values; | ||
var step = getFormatStep((cormax - cormin) / (count - 1), allowDecimals, 0); | ||
var step = getFormatStep(new _decimal2.default(cormax).sub(cormin).div(count - 1), allowDecimals, 0); | ||
var fn = (0, _utils.compose)((0, _utils.map)(function (n) { | ||
return cormin + n * step; | ||
return new _decimal2.default(cormin).add(new _decimal2.default(n).mul(step)).toNumber(); | ||
}), _utils.range); | ||
@@ -267,4 +280,4 @@ | ||
var count = Math.max(tickCount, 2); | ||
var step = getFormatStep((cormax - cormin) / (count - 1), allowDecimals, 0); | ||
var values = [].concat(_toConsumableArray(_arithmetic2.default.rangeStep(cormin, cormax - 0.99 * step, step)), [cormax]); | ||
var step = getFormatStep(new _decimal2.default(cormax).sub(cormin).div(count - 1), allowDecimals, 0); | ||
var values = [].concat(_toConsumableArray(_arithmetic2.default.rangeStep(new _decimal2.default(cormin), new _decimal2.default(cormax).sub(new _decimal2.default(0.99).mul(step)), step)), [cormax]); | ||
@@ -271,0 +284,0 @@ return min > max ? (0, _utils.reverse)(values) : values; |
@@ -7,32 +7,9 @@ 'use strict'; | ||
var _utils = require('./utils'); | ||
var _decimal = require('decimal.js-light'); | ||
/** | ||
* 把错误的数据转正 | ||
* strip(0.09999999999999998)=0.1 | ||
* @param {Number} num 输入值 | ||
* @param {Number} precision 精度 | ||
* @return {Number} 数值 | ||
*/ | ||
function strip(num) { | ||
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 12; | ||
var _decimal2 = _interopRequireDefault(_decimal); | ||
return +parseFloat(num.toPrecision(precision)); | ||
} | ||
var _utils = require('./utils'); | ||
/** | ||
* 判断数据是否为浮点类型 | ||
* | ||
* @param {Number} num 输入值 | ||
* @return {Boolean} 是否是浮点类型 | ||
*/ | ||
/** | ||
* @fileOverview 一些公用的运算方法 | ||
* @author xile611 | ||
* @date 2015-09-17 | ||
*/ | ||
function isFloat(num) { | ||
return (/^([+-]?)\d*\.\d+$/.test(num) | ||
); | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -48,4 +25,8 @@ /** | ||
*/ | ||
/** | ||
* @fileOverview 一些公用的运算方法 | ||
* @author xile611 | ||
* @date 2015-09-17 | ||
*/ | ||
function getDigitCount(value) { | ||
var abs = Math.abs(value); | ||
var result = void 0; | ||
@@ -56,3 +37,3 @@ | ||
} else { | ||
result = Math.floor(Math.log(abs) / Math.log(10)) + 1; | ||
result = Math.floor(new _decimal2.default(value).abs().log(10).toNumber()) + 1; | ||
} | ||
@@ -62,96 +43,20 @@ | ||
} | ||
/** | ||
* 计算数值的小数点后的位数 | ||
* @param {Number} a 数值,可能为整数,也可能为浮点数 | ||
* @return {Integer} 位数 | ||
*/ | ||
function getDecimalDigitCount(a) { | ||
var str = a ? '' + a : ''; | ||
// scientific notation | ||
if (str.indexOf('e') >= 0) { | ||
return Math.abs(parseInt(str.slice(str.indexOf('e') + 1), 10)); | ||
} | ||
var ary = str.split('.'); | ||
return ary.length > 1 ? ary[1].length : 0; | ||
} | ||
/** | ||
* 乘法运算,解决了js运算的精度问题 | ||
* @param {Number} a 被乘数 | ||
* @param {Number} b 乘数 | ||
* @return {Number} 积 | ||
*/ | ||
function multiply(a, b) { | ||
var intA = parseInt(('' + a).replace('.', ''), 10); | ||
var intB = parseInt(('' + b).replace('.', ''), 10); | ||
var count = getDecimalDigitCount(a) + getDecimalDigitCount(b); | ||
return intA * intB / Math.pow(10, count); | ||
} | ||
/** | ||
* 加法运算,解决了js运算的精度问题 | ||
* @param {Number} a 被加数 | ||
* @param {Number} b 加数 | ||
* @return {Number} 和 | ||
*/ | ||
function sum(a, b) { | ||
var count = Math.max(getDecimalDigitCount(a), getDecimalDigitCount(b)); | ||
count = Math.pow(10, count); | ||
return (multiply(a, count) + multiply(b, count)) / count; | ||
} | ||
/** | ||
* 减法运算,解决了js运算的精度问题 | ||
* @param {Number} a 被减数 | ||
* @param {Number} b 减数 | ||
* @return {Number} 差 | ||
*/ | ||
function minus(a, b) { | ||
return sum(a, -b); | ||
} | ||
/** | ||
* 除法运算,解决了js运算的精度问题 | ||
* @param {Number} a 被除数 | ||
* @param {Number} b 除数 | ||
* @return {Number} 结果 | ||
*/ | ||
function divide(a, b) { | ||
var ca = getDecimalDigitCount(a); | ||
var cb = getDecimalDigitCount(b); | ||
var intA = parseInt(('' + a).replace('.', ''), 10); | ||
var intB = parseInt(('' + b).replace('.', ''), 10); | ||
return intA / intB * Math.pow(10, cb - ca); | ||
} | ||
function modulo(a, b) { | ||
var mod = Math.abs(b); | ||
if (b <= 0) { | ||
return a; | ||
} | ||
var cnt = Math.floor(a / mod); | ||
return minus(a, multiply(mod, cnt)); | ||
} | ||
/** | ||
* 按照固定的步长获取[start, end)这个区间的数据 | ||
* 并且需要处理js计算精度的问题 | ||
* | ||
* @param {Number} start 起点 | ||
* @param {Number} end 终点,不包含该值 | ||
* @param {Number} step 步长 | ||
* @return {Array} 若干数值 | ||
* @param {Decimal} start 起点 | ||
* @param {Decimal} end 终点,不包含该值 | ||
* @param {Decimal} step 步长 | ||
* @return {Array} 若干数值 | ||
*/ | ||
function rangeStep(start, end, step) { | ||
var num = start; | ||
var num = new _decimal2.default(start); | ||
var result = []; | ||
while (num < end) { | ||
result.push(num); | ||
while (num.lt(end)) { | ||
result.push(num.toNumber()); | ||
num = sum(num, step); | ||
num = num.add(step); | ||
} | ||
@@ -209,13 +114,4 @@ | ||
rangeStep: rangeStep, | ||
isFloat: isFloat, | ||
getDigitCount: getDigitCount, | ||
getDecimalDigitCount: getDecimalDigitCount, | ||
sum: sum, | ||
minus: minus, | ||
multiply: multiply, | ||
divide: divide, | ||
modulo: modulo, | ||
strip: strip, | ||
interpolateNumber: interpolateNumber, | ||
@@ -222,0 +118,0 @@ uninterpolateNumber: uninterpolateNumber, |
{ | ||
"name": "recharts-scale", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"description": "Scale of Cartesian Coordinates", | ||
@@ -31,2 +31,5 @@ "main": "lib/index", | ||
"homepage": "https://github.com/recharts/recharts-scale", | ||
"dependencies": { | ||
"decimal.js-light": "^2.4.1" | ||
}, | ||
"devDependencies": { | ||
@@ -33,0 +36,0 @@ "babel-cli": "^6.10.0", |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
import Decimal from 'decimal.js-light'; | ||
import { compose, range, memoize, map, reverse } from './util/utils'; | ||
@@ -32,23 +32,25 @@ import Arithmetic from './util/arithmetic'; | ||
* | ||
* @param {Number} roughStep The rough step calculated by deviding the | ||
* @param {Decimal} roughStep The rough step calculated by deviding the | ||
* difference by the tickCount | ||
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not | ||
* @param {Integer} correctionFactor A correction factor | ||
* @return {Number} The step which is easy to understand between two ticks | ||
* @return {Decimal} The step which is easy to understand between two ticks | ||
*/ | ||
function getFormatStep(roughStep, allowDecimals, correctionFactor) { | ||
if (roughStep <= 0) { return 0; } | ||
if (roughStep.lte(0)) { return new Decimal(0); } | ||
const digitCount = Arithmetic.getDigitCount(roughStep); | ||
const digitCount = Arithmetic.getDigitCount(roughStep.toNumber()); | ||
// The ratio between the rough step and the smallest number which has a bigger | ||
// order of magnitudes than the rough step | ||
const stepRatio = roughStep / Math.pow(10, digitCount); | ||
const digitCountValue = new Decimal(10).pow(digitCount); | ||
const stepRatio = roughStep.div(digitCountValue); | ||
// When an integer and a float multiplied, the accuracy of result may be wrong | ||
const amendStepRatio = digitCount !== 1 ? | ||
Arithmetic.multiply(Math.ceil(stepRatio / 0.05) + correctionFactor, 0.05) : | ||
Arithmetic.multiply(Math.ceil(stepRatio / 0.1) + correctionFactor, 0.1); | ||
const stepRatioScale = digitCount !== 1 ? 0.05 : 0.1; | ||
const amendStepRatio = new Decimal( | ||
Math.ceil(stepRatio.div(stepRatioScale).toNumber()) | ||
).add(correctionFactor).mul(stepRatioScale); | ||
const formatStep = Arithmetic.multiply(amendStepRatio, Math.pow(10, digitCount)); | ||
const formatStep = amendStepRatio.mul(digitCountValue); | ||
return allowDecimals ? formatStep : Math.ceil(formatStep); | ||
return allowDecimals ? formatStep : new Decimal(Math.ceil(formatStep)); | ||
} | ||
@@ -65,8 +67,7 @@ | ||
function getTickOfSingleValue(value, tickCount, allowDecimals) { | ||
const isFlt = Arithmetic.isFloat(value); | ||
let step = 1; | ||
// calculate the middle value of ticks | ||
let middle = value; | ||
let middle = new Decimal(value); | ||
if (isFlt && allowDecimals) { | ||
if (!middle.isint() && allowDecimals) { | ||
const absVal = Math.abs(value); | ||
@@ -76,13 +77,13 @@ | ||
// The step should be a float number when the difference is smaller than 1 | ||
step = Math.pow(10, Arithmetic.getDigitCount(value) - 1); | ||
step = new Decimal(10).pow(Arithmetic.getDigitCount(value) - 1); | ||
middle = Arithmetic.multiply(Math.floor(value / step), step); | ||
middle = new Decimal(Math.floor(middle.div(step).toNumber())).mul(step); | ||
} else if (absVal > 1) { | ||
// Return the maximum integer which is smaller than 'value' when 'value' is greater than 1 | ||
middle = Math.floor(value); | ||
middle = new Decimal(Math.floor(value)); | ||
} | ||
} else if (value === 0) { | ||
middle = Math.floor((tickCount - 1) / 2); | ||
middle = new Decimal(Math.floor((tickCount - 1) / 2)); | ||
} else if (!allowDecimals) { | ||
middle = Math.floor(value); | ||
middle = new Decimal(Math.floor(value)); | ||
} | ||
@@ -93,3 +94,3 @@ | ||
const fn = compose( | ||
map(n => Arithmetic.sum(middle, Arithmetic.multiply(n - middleIndex, step))), | ||
map(n => middle.add(new Decimal(n - middleIndex).mul(step)).toNumber()), | ||
range | ||
@@ -112,4 +113,17 @@ ); | ||
function calculateStep(min, max, tickCount, allowDecimals, correctionFactor = 0) { | ||
// dirty hack (for recharts' test) | ||
if (!Number.isFinite((max - min) / (tickCount - 1))) { | ||
return { | ||
step: new Decimal(0), | ||
tickMin: new Decimal(0), | ||
tickMax: new Decimal(0), | ||
}; | ||
} | ||
// The step which is easy to understand between two ticks | ||
const step = getFormatStep((max - min) / (tickCount - 1), allowDecimals, correctionFactor); | ||
const step = getFormatStep( | ||
new Decimal(max).sub(min).div(tickCount - 1), | ||
allowDecimals, | ||
correctionFactor | ||
); | ||
@@ -121,14 +135,13 @@ // A medial value of ticks | ||
if (min <= 0 && max >= 0) { | ||
middle = 0; | ||
middle = new Decimal(0); | ||
} else { | ||
// calculate the middle value | ||
middle = Arithmetic.divide(Arithmetic.sum(min, max), 2); | ||
middle = new Decimal(min).add(max).div(2); | ||
// minus modulo value | ||
middle = Arithmetic.minus(middle, Arithmetic.modulo(middle, step)); | ||
// strip | ||
middle = Arithmetic.strip(middle, 16); | ||
middle = middle.sub(new Decimal(middle).mod(step)); | ||
} | ||
let belowCount = Math.ceil((middle - min) / step); | ||
let upCount = Math.ceil((max - middle) / step); | ||
let belowCount = Math.ceil(middle.sub(min).div(step).toNumber()); | ||
let upCount = Math.ceil(new Decimal(max).sub(middle).div(step) | ||
.toNumber()); | ||
const scaleCount = belowCount + upCount + 1; | ||
@@ -147,4 +160,4 @@ | ||
step, | ||
tickMin: Arithmetic.minus(middle, Arithmetic.multiply(belowCount, step)), | ||
tickMax: Arithmetic.sum(middle, Arithmetic.multiply(upCount, step)), | ||
tickMin: middle.sub(new Decimal(belowCount).mul(step)), | ||
tickMax: middle.add(new Decimal(upCount).mul(step)), | ||
}; | ||
@@ -172,3 +185,3 @@ } | ||
const values = Arithmetic.rangeStep(tickMin, tickMax + 0.1 * step, step); | ||
const values = Arithmetic.rangeStep(tickMin, tickMax.add(new Decimal(0.1).mul(step)), step); | ||
@@ -187,6 +200,6 @@ return min > max ? reverse(values) : values; | ||
const step = getFormatStep((cormax - cormin) / (count - 1), allowDecimals, 0); | ||
const step = getFormatStep(new Decimal(cormax).sub(cormin).div(count - 1), allowDecimals, 0); | ||
const fn = compose( | ||
map(n => (cormin + n * step)), | ||
map(n => new Decimal(cormin).add(new Decimal(n).mul(step)).toNumber()), | ||
range | ||
@@ -207,4 +220,11 @@ ); | ||
const count = Math.max(tickCount, 2); | ||
const step = getFormatStep((cormax - cormin) / (count - 1), allowDecimals, 0); | ||
const values = [...Arithmetic.rangeStep(cormin, cormax - 0.99 * step, step), cormax]; | ||
const step = getFormatStep(new Decimal(cormax).sub(cormin).div(count - 1), allowDecimals, 0); | ||
const values = [ | ||
...Arithmetic.rangeStep( | ||
new Decimal(cormin), | ||
new Decimal(cormax).sub(new Decimal(0.99).mul(step)), | ||
step | ||
), | ||
cormax, | ||
]; | ||
@@ -211,0 +231,0 @@ return min > max ? reverse(values) : values; |
@@ -6,26 +6,6 @@ /** | ||
*/ | ||
import Decimal from 'decimal.js-light'; | ||
import { curry } from './utils'; | ||
/** | ||
* 把错误的数据转正 | ||
* strip(0.09999999999999998)=0.1 | ||
* @param {Number} num 输入值 | ||
* @param {Number} precision 精度 | ||
* @return {Number} 数值 | ||
*/ | ||
function strip(num, precision = 12) { | ||
return +parseFloat(num.toPrecision(precision)); | ||
} | ||
/** | ||
* 判断数据是否为浮点类型 | ||
* | ||
* @param {Number} num 输入值 | ||
* @return {Boolean} 是否是浮点类型 | ||
*/ | ||
function isFloat(num) { | ||
return /^([+-]?)\d*\.\d+$/.test(num); | ||
} | ||
/** | ||
* 获取数值的位数 | ||
@@ -40,3 +20,2 @@ * 其中绝对值属于区间[0.1, 1), 得到的值为0 | ||
function getDigitCount(value) { | ||
const abs = Math.abs(value); | ||
let result; | ||
@@ -47,3 +26,4 @@ | ||
} else { | ||
result = Math.floor(Math.log(abs) / Math.log(10)) + 1; | ||
result = Math.floor(new Decimal(value).abs().log(10) | ||
.toNumber()) + 1; | ||
} | ||
@@ -53,94 +33,20 @@ | ||
} | ||
/** | ||
* 计算数值的小数点后的位数 | ||
* @param {Number} a 数值,可能为整数,也可能为浮点数 | ||
* @return {Integer} 位数 | ||
*/ | ||
function getDecimalDigitCount(a) { | ||
const str = a ? `${a}` : ''; | ||
// scientific notation | ||
if (str.indexOf('e') >= 0) { | ||
return Math.abs(parseInt(str.slice(str.indexOf('e') + 1), 10)); | ||
} | ||
const ary = str.split('.'); | ||
return ary.length > 1 ? ary[1].length : 0; | ||
} | ||
/** | ||
* 乘法运算,解决了js运算的精度问题 | ||
* @param {Number} a 被乘数 | ||
* @param {Number} b 乘数 | ||
* @return {Number} 积 | ||
*/ | ||
function multiply(a, b) { | ||
const intA = parseInt((`${a}`).replace('.', ''), 10); | ||
const intB = parseInt((`${b}`).replace('.', ''), 10); | ||
const count = getDecimalDigitCount(a) + getDecimalDigitCount(b); | ||
return (intA * intB) / Math.pow(10, count); | ||
} | ||
/** | ||
* 加法运算,解决了js运算的精度问题 | ||
* @param {Number} a 被加数 | ||
* @param {Number} b 加数 | ||
* @return {Number} 和 | ||
*/ | ||
function sum(a, b) { | ||
let count = Math.max(getDecimalDigitCount(a), getDecimalDigitCount(b)); | ||
count = Math.pow(10, count); | ||
return (multiply(a, count) + multiply(b, count)) / count; | ||
} | ||
/** | ||
* 减法运算,解决了js运算的精度问题 | ||
* @param {Number} a 被减数 | ||
* @param {Number} b 减数 | ||
* @return {Number} 差 | ||
*/ | ||
function minus(a, b) { | ||
return sum(a, -b); | ||
} | ||
/** | ||
* 除法运算,解决了js运算的精度问题 | ||
* @param {Number} a 被除数 | ||
* @param {Number} b 除数 | ||
* @return {Number} 结果 | ||
*/ | ||
function divide(a, b) { | ||
const ca = getDecimalDigitCount(a); | ||
const cb = getDecimalDigitCount(b); | ||
const intA = parseInt((`${a}`).replace('.', ''), 10); | ||
const intB = parseInt((`${b}`).replace('.', ''), 10); | ||
return (intA / intB) * Math.pow(10, cb - ca); | ||
} | ||
function modulo(a, b) { | ||
const mod = Math.abs(b); | ||
if (b <= 0) { return a; } | ||
const cnt = Math.floor(a / mod); | ||
return minus(a, multiply(mod, cnt)); | ||
} | ||
/** | ||
* 按照固定的步长获取[start, end)这个区间的数据 | ||
* 并且需要处理js计算精度的问题 | ||
* | ||
* @param {Number} start 起点 | ||
* @param {Number} end 终点,不包含该值 | ||
* @param {Number} step 步长 | ||
* @return {Array} 若干数值 | ||
* @param {Decimal} start 起点 | ||
* @param {Decimal} end 终点,不包含该值 | ||
* @param {Decimal} step 步长 | ||
* @return {Array} 若干数值 | ||
*/ | ||
function rangeStep(start, end, step) { | ||
let num = start; | ||
let num = new Decimal(start); | ||
const result = []; | ||
while (num < end) { | ||
result.push(num); | ||
while (num.lt(end)) { | ||
result.push(num.toNumber()); | ||
num = sum(num, step); | ||
num = num.add(step); | ||
} | ||
@@ -198,13 +104,4 @@ | ||
rangeStep, | ||
isFloat, | ||
getDigitCount, | ||
getDecimalDigitCount, | ||
sum, | ||
minus, | ||
multiply, | ||
divide, | ||
modulo, | ||
strip, | ||
interpolateNumber, | ||
@@ -211,0 +108,0 @@ uninterpolateNumber, |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.RechartsScale=t():e.RechartsScale=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var u=r[n]={exports:{},id:n,loaded:!1};return e[n].call(u.exports,u,u.exports,t),u.loaded=!0,u.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2);Object.defineProperty(t,"getTickValues",{enumerable:!0,get:function(){return n.getTickValues}}),Object.defineProperty(t,"getNiceTickValues",{enumerable:!0,get:function(){return n.getNiceTickValues}}),Object.defineProperty(t,"getTickValuesFixedDomain",{enumerable:!0,get:function(){return n.getTickValuesFixedDomain}})},function(e,t){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){return e},u=t.PLACE_HOLDER={"@@functional/placeholder":!0},a=function(e){return e===u},i=function(e){return function t(){return 0===arguments.length||1===arguments.length&&a(arguments.length<=0?void 0:arguments[0])?t:e.apply(void 0,arguments)}},o=function e(t,n){return 1===t?n:i(function(){for(var o=arguments.length,l=Array(o),f=0;f<o;f++)l[f]=arguments[f];var c=l.filter(function(e){return e!==u}).length;return c>=t?n.apply(void 0,l):e(t-c,i(function(){for(var e=arguments.length,t=Array(e),u=0;u<e;u++)t[u]=arguments[u];var i=l.map(function(e){return a(e)?t.shift():e});return n.apply(void 0,r(i).concat(t))}))})},l=t.curry=function(e){return o(e.length,e)};t.range=function(e,t){for(var r=[],n=e;n<t;++n)r[n-e]=n;return r},t.map=l(function(e,t){return Array.isArray(t)?t.map(e):Object.keys(t).map(function(e){return t[e]}).map(e)}),t.compose=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];if(!t.length)return n;var u=t.reverse(),a=u[0],i=u.slice(1);return function(){return i.reduce(function(e,t){return t(e)},a.apply(void 0,arguments))}},t.reverse=function(e){return Array.isArray(e)?e.reverse():e.split("").reverse.join("")},t.memoize=function(e){var t=null,r=null;return function(){for(var n=arguments.length,u=Array(n),a=0;a<n;a++)u[a]=arguments[a];return t&&u.every(function(e,r){return e===t[r]})?r:(t=u,r=e.apply(void 0,u))}}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function u(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function a(e){var t=p(e,2),r=t[0],n=t[1],u=r,a=n;return r>n&&(u=n,a=r),[u,a]}function i(e,t,r){if(e<=0)return 0;var n=h.default.getDigitCount(e),u=e/Math.pow(10,n),a=1!==n?h.default.multiply(Math.ceil(u/.05)+r,.05):h.default.multiply(Math.ceil(u/.1)+r,.1),i=h.default.multiply(a,Math.pow(10,n));return t?i:Math.ceil(i)}function o(e,t,r){var n=h.default.isFloat(e),u=1,a=e;if(n&&r){var i=Math.abs(e);i<1?(u=Math.pow(10,h.default.getDigitCount(e)-1),a=h.default.multiply(Math.floor(e/u),u)):i>1&&(a=Math.floor(e))}else 0===e?a=Math.floor((t-1)/2):r||(a=Math.floor(e));var o=Math.floor((t-1)/2),l=(0,d.compose)((0,d.map)(function(e){return h.default.sum(a,h.default.multiply(e-o,u))}),d.range);return l(0,t)}function l(e,t,r,n){var u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=i((t-e)/(r-1),n,u),o=void 0;e<=0&&t>=0?o=0:(o=h.default.divide(h.default.sum(e,t),2),o=h.default.minus(o,h.default.modulo(o,a)),o=h.default.strip(o,16));var f=Math.ceil((o-e)/a),c=Math.ceil((t-o)/a),s=f+c+1;return s>r?l(e,t,r,n,u+1):(s<r&&(c=t>0?c+(r-s):c,f=t>0?f:f+(r-s)),{step:a,tickMin:h.default.minus(o,h.default.multiply(f,a)),tickMax:h.default.sum(o,h.default.multiply(c,a))})}function f(e){var t=p(e,2),r=t[0],n=t[1],u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],f=Math.max(u,2),c=a([r,n]),s=p(c,2),v=s[0],m=s[1];if(v===m)return o(v,u,i);var g=l(v,m,f,i),y=g.step,M=g.tickMin,b=g.tickMax,x=h.default.rangeStep(M,b+.1*y,y);return r>n?(0,d.reverse)(x):x}function c(e){var t=p(e,2),r=t[0],n=t[1],u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6,l=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],f=Math.max(u,2),c=a([r,n]),s=p(c,2),v=s[0],h=s[1];if(v===h)return o(v,u,l);var m=i((h-v)/(f-1),l,0),g=(0,d.compose)((0,d.map)(function(e){return v+e*m}),d.range),y=g(0,f).filter(function(e){return e>=v&&e<=h});return r>n?(0,d.reverse)(y):y}function s(e,t){var r=p(e,2),n=r[0],o=r[1],l=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],f=a([n,o]),c=p(f,2),s=c[0],v=c[1];if(s===v)return[s];var m=Math.max(t,2),g=i((v-s)/(m-1),l,0),y=[].concat(u(h.default.rangeStep(s,v-.99*g,g)),[v]);return n>o?(0,d.reverse)(y):y}Object.defineProperty(t,"__esModule",{value:!0}),t.getTickValuesFixedDomain=t.getTickValues=t.getNiceTickValues=void 0;var p=function(){function e(e,t){var r=[],n=!0,u=!1,a=void 0;try{for(var i,o=e[Symbol.iterator]();!(n=(i=o.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){u=!0,a=e}finally{try{!n&&o.return&&o.return()}finally{if(u)throw a}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),d=r(1),v=r(3),h=n(v);t.getNiceTickValues=(0,d.memoize)(f),t.getTickValues=(0,d.memoize)(c),t.getTickValuesFixedDomain=(0,d.memoize)(s)},function(e,t,r){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12;return+parseFloat(e.toPrecision(t))}function u(e){return/^([+-]?)\d*\.\d+$/.test(e)}function a(e){var t=Math.abs(e),r=void 0;return r=0===e?1:Math.floor(Math.log(t)/Math.log(10))+1}function i(e){var t=e?""+e:"";if(t.indexOf("e")>=0)return Math.abs(parseInt(t.slice(t.indexOf("e")+1),10));var r=t.split(".");return r.length>1?r[1].length:0}function o(e,t){var r=parseInt((""+e).replace(".",""),10),n=parseInt((""+t).replace(".",""),10),u=i(e)+i(t);return r*n/Math.pow(10,u)}function l(e,t){var r=Math.max(i(e),i(t));return r=Math.pow(10,r),(o(e,r)+o(t,r))/r}function f(e,t){return l(e,-t)}function c(e,t){var r=i(e),n=i(t),u=parseInt((""+e).replace(".",""),10),a=parseInt((""+t).replace(".",""),10);return u/a*Math.pow(10,n-r)}function s(e,t){var r=Math.abs(t);if(t<=0)return e;var n=Math.floor(e/r);return f(e,o(r,n))}function p(e,t,r){for(var n=e,u=[];n<t;)u.push(n),n=l(n,r);return u}Object.defineProperty(t,"__esModule",{value:!0});var d=r(1),v=(0,d.curry)(function(e,t,r){var n=+e,u=+t;return n+r*(u-n)}),h=(0,d.curry)(function(e,t,r){var n=t-+e;return n=n||1/0,(r-e)/n}),m=(0,d.curry)(function(e,t,r){var n=t-+e;return n=n||1/0,Math.max(0,Math.min(1,(r-e)/n))});t.default={rangeStep:p,isFloat:u,getDigitCount:a,getDecimalDigitCount:i,sum:l,minus:f,multiply:o,divide:c,modulo:s,strip:n,interpolateNumber:v,uninterpolateNumber:h,uninterpolateTruncation:m}}])}); | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.RechartsScale=r():e.RechartsScale=r()}(this,function(){return function(e){function r(n){if(t[n])return t[n].exports;var i=t[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=t(3);Object.defineProperty(r,"getTickValues",{enumerable:!0,get:function(){return n.getTickValues}}),Object.defineProperty(r,"getNiceTickValues",{enumerable:!0,get:function(){return n.getNiceTickValues}}),Object.defineProperty(r,"getTickValuesFixedDomain",{enumerable:!0,get:function(){return n.getTickValuesFixedDomain}})},function(e,r){"use strict";function t(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)}Object.defineProperty(r,"__esModule",{value:!0});var n=function(e){return e},i=r.PLACE_HOLDER={"@@functional/placeholder":!0},o=function(e){return e===i},u=function(e){return function r(){return 0===arguments.length||1===arguments.length&&o(arguments.length<=0?void 0:arguments[0])?r:e.apply(void 0,arguments)}},s=function e(r,n){return 1===r?n:u(function(){for(var s=arguments.length,f=Array(s),c=0;c<s;c++)f[c]=arguments[c];var a=f.filter(function(e){return e!==i}).length;return a>=r?n.apply(void 0,f):e(r-a,u(function(){for(var e=arguments.length,r=Array(e),i=0;i<e;i++)r[i]=arguments[i];var u=f.map(function(e){return o(e)?r.shift():e});return n.apply(void 0,t(u).concat(r))}))})},f=r.curry=function(e){return s(e.length,e)};r.range=function(e,r){for(var t=[],n=e;n<r;++n)t[n-e]=n;return t},r.map=f(function(e,r){return Array.isArray(r)?r.map(e):Object.keys(r).map(function(e){return r[e]}).map(e)}),r.compose=function(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++)r[t]=arguments[t];if(!r.length)return n;var i=r.reverse(),o=i[0],u=i.slice(1);return function(){return u.reduce(function(e,r){return r(e)},o.apply(void 0,arguments))}},r.reverse=function(e){return Array.isArray(e)?e.reverse():e.split("").reverse.join("")},r.memoize=function(e){var r=null,t=null;return function(){for(var n=arguments.length,i=Array(n),o=0;o<n;o++)i[o]=arguments[o];return r&&i.every(function(e,t){return e===r[t]})?t:(r=i,t=e.apply(void 0,i))}}},function(e,r,t){var n;!function(i){"use strict";function o(e,r){var t,n,i,o,u,s,f,c,a=e.constructor,l=a.precision;if(!e.s||!r.s)return r.s||(r=new a(e)),E?v(r,l):r;if(f=e.d,c=r.d,u=e.e,i=r.e,f=f.slice(),o=u-i){for(o<0?(n=f,o=-o,s=c.length):(n=c,i=u,s=f.length),u=Math.ceil(l/P),s=u>s?u+1:s+1,o>s&&(o=s,n.length=1),n.reverse();o--;)n.push(0);n.reverse()}for(s=f.length,o=c.length,s-o<0&&(o=s,n=c,c=f,f=n),t=0;o;)t=(f[--o]=f[o]+c[o]+t)/T|0,f[o]%=T;for(t&&(f.unshift(t),++i),s=f.length;0==f[--s];)f.pop();return r.d=f,r.e=i,E?v(r,l):r}function u(e,r,t){if(e!==~~e||e<r||e>t)throw Error(O+e)}function s(e){var r,t,n,i=e.length-1,o="",u=e[0];if(i>0){for(o+=u,r=1;r<i;r++)n=e[r]+"",t=P-n.length,t&&(o+=l(t)),o+=n;u=e[r],n=u+"",t=P-n.length,t&&(o+=l(t))}else if(0===u)return"0";for(;u%10===0;)u/=10;return o+u}function f(e,r){var t,n,i,o,u,f,a=0,l=0,d=e.constructor,h=d.precision;if(c(e)>16)throw Error(A+c(e));if(!e.s)return new d(y);for(null==r?(E=!1,f=h):f=r,u=new d(.03125);e.abs().gte(.1);)e=e.times(u),l+=5;for(n=Math.log(k(2,l))/Math.LN10*2+5|0,f+=n,t=i=o=new d(y),d.precision=f;;){if(i=v(i.times(e),f),t=t.times(++a),u=o.plus(R(i,t,f)),s(u.d).slice(0,f)===s(o.d).slice(0,f)){for(;l--;)o=v(o.times(o),f);return d.precision=h,null==r?(E=!0,v(o,h)):o}o=u}}function c(e){for(var r=e.e*P,t=e.d[0];t>=10;t/=10)r++;return r}function a(e,r,t){if(r>e.LN10.sd())throw E=!0,t&&(e.precision=t),Error(M+"LN10 precision limit exceeded");return v(new e(e.LN10),r)}function l(e){for(var r="";e--;)r+="0";return r}function d(e,r){var t,n,i,o,u,f,l,h,g,p=1,w=10,m=e,b=m.d,N=m.constructor,x=N.precision;if(m.s<1)throw Error(M+(m.s?"NaN":"-Infinity"));if(m.eq(y))return new N(0);if(null==r?(E=!1,h=x):h=r,m.eq(10))return null==r&&(E=!0),a(N,h);if(h+=w,N.precision=h,t=s(b),n=t.charAt(0),o=c(m),!(Math.abs(o)<15e14))return l=a(N,h+2,x).times(o+""),m=d(new N(n+"."+t.slice(1)),h-w).plus(l),N.precision=x,null==r?(E=!0,v(m,x)):m;for(;n<7&&1!=n||1==n&&t.charAt(1)>3;)m=m.times(e),t=s(m.d),n=t.charAt(0),p++;for(o=c(m),n>1?(m=new N("0."+t),o++):m=new N(n+"."+t.slice(1)),f=u=m=R(m.minus(y),m.plus(y),h),g=v(m.times(m),h),i=3;;){if(u=v(u.times(g),h),l=f.plus(R(u,new N(i),h)),s(l.d).slice(0,h)===s(f.d).slice(0,h))return f=f.times(2),0!==o&&(f=f.plus(a(N,h+2,x).times(o+""))),f=R(f,new N(p),h),N.precision=x,null==r?(E=!0,v(f,x)):f;f=l,i+=2}}function h(e,r){var t,n,i;for((t=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(t<0&&(t=n),t+=+r.slice(n+1),r=r.substring(0,n)):t<0&&(t=r.length),n=0;48===r.charCodeAt(n);)++n;for(i=r.length;48===r.charCodeAt(i-1);)--i;if(r=r.slice(n,i)){if(i-=n,t=t-n-1,e.e=_(t/P),e.d=[],n=(t+1)%P,t<0&&(n+=P),n<i){for(n&&e.d.push(+r.slice(0,n)),i-=P;n<i;)e.d.push(+r.slice(n,n+=P));r=r.slice(n),n=P-r.length}else n-=i;for(;n--;)r+="0";if(e.d.push(+r),E&&(e.e>j||e.e<-j))throw Error(A+t)}else e.s=0,e.e=0,e.d=[0];return e}function v(e,r,t){var n,i,o,u,s,f,a,l,d=e.d;for(u=1,o=d[0];o>=10;o/=10)u++;if(n=r-u,n<0)n+=P,i=r,a=d[l=0];else{if(l=Math.ceil((n+1)/P),o=d.length,l>=o)return e;for(a=o=d[l],u=1;o>=10;o/=10)u++;n%=P,i=n-P+u}if(void 0!==t&&(o=k(10,u-i-1),s=a/o%10|0,f=r<0||void 0!==d[l+1]||a%o,f=t<4?(s||f)&&(0==t||t==(e.s<0?3:2)):s>5||5==s&&(4==t||f||6==t&&(n>0?i>0?a/k(10,u-i):0:d[l-1])%10&1||t==(e.s<0?8:7))),r<1||!d[0])return f?(o=c(e),d.length=1,r=r-o-1,d[0]=k(10,(P-r%P)%P),e.e=_(-r/P)||0):(d.length=1,d[0]=e.e=e.s=0),e;if(0==n?(d.length=l,o=1,l--):(d.length=l+1,o=k(10,P-n),d[l]=i>0?(a/k(10,u-i)%k(10,i)|0)*o:0),f)for(;;){if(0==l){(d[0]+=o)==T&&(d[0]=1,++e.e);break}if(d[l]+=o,d[l]!=T)break;d[l--]=0,o=1}for(n=d.length;0===d[--n];)d.pop();if(E&&(e.e>j||e.e<-j))throw Error(A+c(e));return e}function g(e,r){var t,n,i,o,u,s,f,c,a,l,d=e.constructor,h=d.precision;if(!e.s||!r.s)return r.s?r.s=-r.s:r=new d(e),E?v(r,h):r;if(f=e.d,l=r.d,n=r.e,c=e.e,f=f.slice(),u=c-n){for(a=u<0,a?(t=f,u=-u,s=l.length):(t=l,n=c,s=f.length),i=Math.max(Math.ceil(h/P),s)+2,u>i&&(u=i,t.length=1),t.reverse(),i=u;i--;)t.push(0);t.reverse()}else{for(i=f.length,s=l.length,a=i<s,a&&(s=i),i=0;i<s;i++)if(f[i]!=l[i]){a=f[i]<l[i];break}u=0}for(a&&(t=f,f=l,l=t,r.s=-r.s),s=f.length,i=l.length-s;i>0;--i)f[s++]=0;for(i=l.length;i>u;){if(f[--i]<l[i]){for(o=i;o&&0===f[--o];)f[o]=T-1;--f[o],f[i]+=T}f[i]-=l[i]}for(;0===f[--s];)f.pop();for(;0===f[0];f.shift())--n;return f[0]?(r.d=f,r.e=n,E?v(r,h):r):new d(0)}function p(e,r,t){var n,i=c(e),o=s(e.d),u=o.length;return r?(t&&(n=t-u)>0?o=o.charAt(0)+"."+o.slice(1)+l(n):u>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(i<0?"e":"e+")+i):i<0?(o="0."+l(-i-1)+o,t&&(n=t-u)>0&&(o+=l(n))):i>=u?(o+=l(i+1-u),t&&(n=t-i-1)>0&&(o=o+"."+l(n))):((n=i+1)<u&&(o=o.slice(0,n)+"."+o.slice(n)),t&&(n=t-u)>0&&(i+1===u&&(o+="."),o+=l(n))),e.s<0?"-"+o:o}function w(e,r){if(e.length>r)return e.length=r,!0}function m(e){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(t.constructor=r,e instanceof r)return t.s=e.s,t.e=e.e,void(t.d=(e=e.d)?e.slice():e);if("number"==typeof e){if(0*e!==0)throw Error(O+e);if(e>0)t.s=1;else{if(!(e<0))return t.s=0,t.e=0,void(t.d=[0]);e=-e,t.s=-1}return e===~~e&&e<1e7?(t.e=0,void(t.d=[e])):h(t,e.toString())}if("string"!=typeof e)throw Error(O+e);if(45===e.charCodeAt(0)?(e=e.slice(1),t.s=-1):t.s=1,!D.test(e))throw Error(O+e);h(t,e)}var t,n,i;if(r.prototype=q,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.clone=m,r.config=r.set=b,void 0===e&&(e={}),e)for(i=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t<i.length;)e.hasOwnProperty(n=i[t++])||(e[n]=this[n]);return r.config(e),r}function b(e){if(!e||"object"!=typeof e)throw Error(M+"Object expected");var r,t,n,i=["precision",1,N,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(r=0;r<i.length;r+=3)if(void 0!==(n=e[t=i[r]])){if(!(_(n)===n&&n>=i[r+1]&&n<=i[r+2]))throw Error(O+t+": "+n);this[t]=n}if(void 0!==(n=e[t="LN10"])){if(n!=Math.LN10)throw Error(O+t+": "+n);this[t]=new this(n)}return this}var y,N=1e9,x={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},E=!0,M="[DecimalError] ",O=M+"Invalid argument: ",A=M+"Exponent out of range: ",_=Math.floor,k=Math.pow,D=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,T=1e7,P=7,L=9007199254740991,j=_(L/P),q={};q.absoluteValue=q.abs=function(){var e=new this.constructor(this);return e.s&&(e.s=1),e},q.comparedTo=q.cmp=function(e){var r,t,n,i,o=this;if(e=new o.constructor(e),o.s!==e.s)return o.s||-e.s;if(o.e!==e.e)return o.e>e.e^o.s<0?1:-1;for(n=o.d.length,i=e.d.length,r=0,t=n<i?n:i;r<t;++r)if(o.d[r]!==e.d[r])return o.d[r]>e.d[r]^o.s<0?1:-1;return n===i?0:n>i^o.s<0?1:-1},q.decimalPlaces=q.dp=function(){var e=this,r=e.d.length-1,t=(r-e.e)*P;if(r=e.d[r])for(;r%10==0;r/=10)t--;return t<0?0:t},q.dividedBy=q.div=function(e){return R(this,new this.constructor(e))},q.dividedToIntegerBy=q.idiv=function(e){var r=this,t=r.constructor;return v(R(r,new t(e),0,1),t.precision)},q.equals=q.eq=function(e){return!this.cmp(e)},q.exponent=function(){return c(this)},q.greaterThan=q.gt=function(e){return this.cmp(e)>0},q.greaterThanOrEqualTo=q.gte=function(e){return this.cmp(e)>=0},q.isInteger=q.isint=function(){return this.e>this.d.length-2},q.isNegative=q.isneg=function(){return this.s<0},q.isPositive=q.ispos=function(){return this.s>0},q.isZero=function(){return 0===this.s},q.lessThan=q.lt=function(e){return this.cmp(e)<0},q.lessThanOrEqualTo=q.lte=function(e){return this.cmp(e)<1},q.logarithm=q.log=function(e){var r,t=this,n=t.constructor,i=n.precision,o=i+5;if(void 0===e)e=new n(10);else if(e=new n(e),e.s<1||e.eq(y))throw Error(M+"NaN");if(t.s<1)throw Error(M+(t.s?"NaN":"-Infinity"));return t.eq(y)?new n(0):(E=!1,r=R(d(t,o),d(e,o),o),E=!0,v(r,i))},q.minus=q.sub=function(e){var r=this;return e=new r.constructor(e),r.s==e.s?g(r,e):o(r,(e.s=-e.s,e))},q.modulo=q.mod=function(e){var r,t=this,n=t.constructor,i=n.precision;if(e=new n(e),!e.s)throw Error(M+"NaN");return t.s?(E=!1,r=R(t,e,0,1).times(e),E=!0,t.minus(r)):v(new n(t),i)},q.naturalExponential=q.exp=function(){return f(this)},q.naturalLogarithm=q.ln=function(){return d(this)},q.negated=q.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},q.plus=q.add=function(e){var r=this;return e=new r.constructor(e),r.s==e.s?o(r,e):g(r,(e.s=-e.s,e))},q.precision=q.sd=function(e){var r,t,n,i=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(O+e);if(r=c(i)+1,n=i.d.length-1,t=n*P+1,n=i.d[n]){for(;n%10==0;n/=10)t--;for(n=i.d[0];n>=10;n/=10)t++}return e&&r>t?r:t},q.squareRoot=q.sqrt=function(){var e,r,t,n,i,o,u,f=this,a=f.constructor;if(f.s<1){if(!f.s)return new a(0);throw Error(M+"NaN")}for(e=c(f),E=!1,i=Math.sqrt(+f),0==i||i==1/0?(r=s(f.d),(r.length+e)%2==0&&(r+="0"),i=Math.sqrt(r),e=_((e+1)/2)-(e<0||e%2),i==1/0?r="1e"+e:(r=i.toExponential(),r=r.slice(0,r.indexOf("e")+1)+e),n=new a(r)):n=new a(i.toString()),t=a.precision,i=u=t+3;;)if(o=n,n=o.plus(R(f,o,u+2)).times(.5),s(o.d).slice(0,u)===(r=s(n.d)).slice(0,u)){if(r=r.slice(u-3,u+1),i==u&&"4999"==r){if(v(o,t+1,0),o.times(o).eq(f)){n=o;break}}else if("9999"!=r)break;u+=4}return E=!0,v(n,t)},q.times=q.mul=function(e){var r,t,n,i,o,u,s,f,c,a=this,l=a.constructor,d=a.d,h=(e=new l(e)).d;if(!a.s||!e.s)return new l(0);for(e.s*=a.s,t=a.e+e.e,f=d.length,c=h.length,f<c&&(o=d,d=h,h=o,u=f,f=c,c=u),o=[],u=f+c,n=u;n--;)o.push(0);for(n=c;--n>=0;){for(r=0,i=f+n;i>n;)s=o[i]+h[n]*d[i-n-1]+r,o[i--]=s%T|0,r=s/T|0;o[i]=(o[i]+r)%T|0}for(;!o[--u];)o.pop();return r?++t:o.shift(),e.d=o,e.e=t,E?v(e,l.precision):e},q.toDecimalPlaces=q.todp=function(e,r){var t=this,n=t.constructor;return t=new n(t),void 0===e?t:(u(e,0,N),void 0===r?r=n.rounding:u(r,0,8),v(t,e+c(t)+1,r))},q.toExponential=function(e,r){var t,n=this,i=n.constructor;return void 0===e?t=p(n,!0):(u(e,0,N),void 0===r?r=i.rounding:u(r,0,8),n=v(new i(n),e+1,r),t=p(n,!0,e+1)),t},q.toFixed=function(e,r){var t,n,i=this,o=i.constructor;return void 0===e?p(i):(u(e,0,N),void 0===r?r=o.rounding:u(r,0,8),n=v(new o(i),e+c(i)+1,r),t=p(n.abs(),!1,e+c(n)+1),i.isneg()&&!i.isZero()?"-"+t:t)},q.toInteger=q.toint=function(){var e=this,r=e.constructor;return v(new r(e),c(e)+1,r.rounding)},q.toNumber=function(){return+this},q.toPower=q.pow=function(e){var r,t,n,i,o,u,s=this,c=s.constructor,a=12,l=+(e=new c(e));if(!e.s)return new c(y);if(s=new c(s),!s.s){if(e.s<1)throw Error(M+"Infinity");return s}if(s.eq(y))return s;if(n=c.precision,e.eq(y))return v(s,n);if(r=e.e,t=e.d.length-1,u=r>=t,o=s.s,u){if((t=l<0?-l:l)<=L){for(i=new c(y),r=Math.ceil(n/P+4),E=!1;t%2&&(i=i.times(s),w(i.d,r)),t=_(t/2),0!==t;)s=s.times(s),w(s.d,r);return E=!0,e.s<0?new c(y).div(i):v(i,n)}}else if(o<0)throw Error(M+"NaN");return o=o<0&&1&e.d[Math.max(r,t)]?-1:1,s.s=1,E=!1,i=e.times(d(s,n+a)),E=!0,i=f(i),i.s=o,i},q.toPrecision=function(e,r){var t,n,i=this,o=i.constructor;return void 0===e?(t=c(i),n=p(i,t<=o.toExpNeg||t>=o.toExpPos)):(u(e,1,N),void 0===r?r=o.rounding:u(r,0,8),i=v(new o(i),e,r),t=c(i),n=p(i,e<=t||t<=o.toExpNeg,e)),n},q.toSignificantDigits=q.tosd=function(e,r){var t=this,n=t.constructor;return void 0===e?(e=n.precision,r=n.rounding):(u(e,1,N),void 0===r?r=n.rounding:u(r,0,8)),v(new n(t),e,r)},q.toString=q.valueOf=q.val=q.toJSON=function(){var e=this,r=c(e),t=e.constructor;return p(e,r<=t.toExpNeg||r>=t.toExpPos)};var R=function(){function e(e,r){var t,n=0,i=e.length;for(e=e.slice();i--;)t=e[i]*r+n,e[i]=t%T|0,n=t/T|0;return n&&e.unshift(n),e}function r(e,r,t,n){var i,o;if(t!=n)o=t>n?1:-1;else for(i=o=0;i<t;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function t(e,r,t){for(var n=0;t--;)e[t]-=n,n=e[t]<r[t]?1:0,e[t]=n*T+e[t]-r[t];for(;!e[0]&&e.length>1;)e.shift()}return function(n,i,o,u){var s,f,a,l,d,h,g,p,w,m,b,y,N,x,E,O,A,_,k=n.constructor,D=n.s==i.s?1:-1,L=n.d,j=i.d;if(!n.s)return new k(n);if(!i.s)throw Error(M+"Division by zero");for(f=n.e-i.e,A=j.length,E=L.length,g=new k(D),p=g.d=[],a=0;j[a]==(L[a]||0);)++a;if(j[a]>(L[a]||0)&&--f,y=null==o?o=k.precision:u?o+(c(n)-c(i))+1:o,y<0)return new k(0);if(y=y/P+2|0,a=0,1==A)for(l=0,j=j[0],y++;(a<E||l)&&y--;a++)N=l*T+(L[a]||0),p[a]=N/j|0,l=N%j|0;else{for(l=T/(j[0]+1)|0,l>1&&(j=e(j,l),L=e(L,l),A=j.length,E=L.length),x=A,w=L.slice(0,A),m=w.length;m<A;)w[m++]=0;_=j.slice(),_.unshift(0),O=j[0],j[1]>=T/2&&++O;do l=0,s=r(j,w,A,m),s<0?(b=w[0],A!=m&&(b=b*T+(w[1]||0)),l=b/O|0,l>1?(l>=T&&(l=T-1),d=e(j,l),h=d.length,m=w.length,s=r(d,w,h,m),1==s&&(l--,t(d,A<h?_:j,h))):(0==l&&(s=l=1),d=j.slice()),h=d.length,h<m&&d.unshift(0),t(w,d,m),s==-1&&(m=w.length,s=r(j,w,A,m),s<1&&(l++,t(w,A<m?_:j,m))),m=w.length):0===s&&(l++,w=[0]),p[a++]=l,s&&w[0]?w[m++]=L[x]||0:(w=[L[x]],m=1);while((x++<E||void 0!==w[0])&&y--)}return p[0]||p.shift(),g.e=f,v(g,u?o+c(g)+1:o)}}();x=m(x),x.default=x.Decimal=x,y=new x(1),n=function(){return x}.call(r,t,r,e),!(void 0!==n&&(e.exports=n))}(this)},function(e,r,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)}function o(e){var r=d(e,2),t=r[0],n=r[1],i=t,o=n;return t>n&&(i=n,o=t),[i,o]}function u(e,r,t){if(e.lte(0))return new v.default(0);var n=w.default.getDigitCount(e.toNumber()),i=new v.default(10).pow(n),o=e.div(i),u=1!==n?.05:.1,s=new v.default(Math.ceil(o.div(u).toNumber())).add(t).mul(u),f=s.mul(i);return r?f:new v.default(Math.ceil(f))}function s(e,r,t){var n=1,i=new v.default(e);if(!i.isint()&&t){var o=Math.abs(e);o<1?(n=new v.default(10).pow(w.default.getDigitCount(e)-1),i=new v.default(Math.floor(i.div(n).toNumber())).mul(n)):o>1&&(i=new v.default(Math.floor(e)))}else 0===e?i=new v.default(Math.floor((r-1)/2)):t||(i=new v.default(Math.floor(e)));var u=Math.floor((r-1)/2),s=(0,g.compose)((0,g.map)(function(e){return i.add(new v.default(e-u).mul(n)).toNumber()}),g.range);return s(0,r)}function f(e,r,t,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(!Number.isFinite((r-e)/(t-1)))return{step:new v.default(0),tickMin:new v.default(0),tickMax:new v.default(0)};var o=u(new v.default(r).sub(e).div(t-1),n,i),s=void 0;e<=0&&r>=0?s=new v.default(0):(s=new v.default(e).add(r).div(2),s=s.sub(new v.default(s).mod(o)));var c=Math.ceil(s.sub(e).div(o).toNumber()),a=Math.ceil(new v.default(r).sub(s).div(o).toNumber()),l=c+a+1;return l>t?f(e,r,t,n,i+1):(l<t&&(a=r>0?a+(t-l):a,c=r>0?c:c+(t-l)),{step:o,tickMin:s.sub(new v.default(c).mul(o)),tickMax:s.add(new v.default(a).mul(o))})}function c(e){var r=d(e,2),t=r[0],n=r[1],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6,u=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],c=Math.max(i,2),a=o([t,n]),l=d(a,2),h=l[0],p=l[1];if(h===p)return s(h,i,u);var m=f(h,p,c,u),b=m.step,y=m.tickMin,N=m.tickMax,x=w.default.rangeStep(y,N.add(new v.default(.1).mul(b)),b);return t>n?(0,g.reverse)(x):x}function a(e){var r=d(e,2),t=r[0],n=r[1],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6,f=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],c=Math.max(i,2),a=o([t,n]),l=d(a,2),h=l[0],p=l[1];if(h===p)return s(h,i,f);var w=u(new v.default(p).sub(h).div(c-1),f,0),m=(0,g.compose)((0,g.map)(function(e){return new v.default(h).add(new v.default(e).mul(w)).toNumber()}),g.range),b=m(0,c).filter(function(e){return e>=h&&e<=p});return t>n?(0,g.reverse)(b):b}function l(e,r){var t=d(e,2),n=t[0],s=t[1],f=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],c=o([n,s]),a=d(c,2),l=a[0],h=a[1];if(l===h)return[l];var p=Math.max(r,2),m=u(new v.default(h).sub(l).div(p-1),f,0),b=[].concat(i(w.default.rangeStep(new v.default(l),new v.default(h).sub(new v.default(.99).mul(m)),m)),[h]);return n>s?(0,g.reverse)(b):b}Object.defineProperty(r,"__esModule",{value:!0}),r.getTickValuesFixedDomain=r.getTickValues=r.getNiceTickValues=void 0;var d=function(){function e(e,r){var t=[],n=!0,i=!1,o=void 0;try{for(var u,s=e[Symbol.iterator]();!(n=(u=s.next()).done)&&(t.push(u.value),!r||t.length!==r);n=!0);}catch(e){i=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return t}return function(r,t){if(Array.isArray(r))return r;if(Symbol.iterator in Object(r))return e(r,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),h=t(2),v=n(h),g=t(1),p=t(4),w=n(p);r.getNiceTickValues=(0,g.memoize)(c),r.getTickValues=(0,g.memoize)(a),r.getTickValuesFixedDomain=(0,g.memoize)(l)},function(e,r,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){var r=void 0;return r=0===e?1:Math.floor(new s.default(e).abs().log(10).toNumber())+1}function o(e,r,t){for(var n=new s.default(e),i=[];n.lt(r);)i.push(n.toNumber()),n=n.add(t);return i}Object.defineProperty(r,"__esModule",{value:!0});var u=t(2),s=n(u),f=t(1),c=(0,f.curry)(function(e,r,t){var n=+e,i=+r;return n+t*(i-n)}),a=(0,f.curry)(function(e,r,t){var n=r-+e;return n=n||1/0,(t-e)/n}),l=(0,f.curry)(function(e,r,t){var n=r-+e;return n=n||1/0,Math.max(0,Math.min(1,(t-e)/n))});r.default={rangeStep:o,getDigitCount:i,interpolateNumber:c,uninterpolateNumber:a,uninterpolateTruncation:l}}])}); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
153789
3332
1
+ Addeddecimal.js-light@^2.4.1
+ Addeddecimal.js-light@2.5.1(transitive)