main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

91
node_modules/recharts-scale/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,91 @@
## 0.4.5 (Mar 25, 2021)
### chore
- fix: previous release
## 0.4.4 (Mar 18, 2021)
### chore
- bring up all dev deps (incl. eslint and webpack) to the latest
- move CI to Github actions
- add linting and building to ci pipeline (in addition to unit testing)
## 0.4.0 (Seq 28, 2018)
### feat
- use `decimal.js-light` to handle large number or high precision
## 0.3.2 (Aug 21, 2017)
### fix
- fix `getNiceTickValues` when the number is a scientific notation
## 0.3.1 (Jun 11, 2017)
### fix
- fix `getDigitCount` when the number is a scientific notation
## 0.3.0 (Mar 01, 2017)
### feat
- Add new ticks function `getTickValuesFixedDomain`
## 0.2.3 (Feb 28, 2017)
### fix
- Fix calculation precision of calculateStep, add Arithmetic.modulo
## 0.2.2 (Feb 28, 2017)
### fix
- Fix calculation precision of calculateStep
## 0.2.1 (July 25, 2016)
### fix
- Fix the precision of ticks for decimals
## 0.2.0 (July 25, 2016)
### feat
- Support `allowDecimals` option
## 0.1.11 (July 19, 2016)
### fix
- Tweak the strategy of calculating step of ticks
## 0.1.10 (July 07, 2016)
### deps
- update deps and fix lint error
## 0.1.9 (April 08, 2016)
### fix
- Fix ticks for interval [0, 0]
## 0.1.8 (Feb 04, 2016)
### refactor
- Refactor the export method
## 0.1.7 (Feb 04, 2016)
### chore
- Optimize npm script commands

22
node_modules/recharts-scale/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Sen Yang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

5
node_modules/recharts-scale/README.md generated vendored Normal file
View File

@@ -0,0 +1,5 @@
# recharts-scale
[![Build Status](https://github.com/recharts/recharts-scale/workflows/ci/badge.svg)](https://github.com/recharts/recharts-scale/actions)
Scale of Cartesian Coordinates

306
node_modules/recharts-scale/es6/getNiceTickValues.js generated vendored Normal file
View File

@@ -0,0 +1,306 @@
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
/**
* @fileOverview calculate tick values of scale
* @author xile611, arcthur
* @date 2015-09-17
*/
import Decimal from 'decimal.js-light';
import { compose, range, memoize, map, reverse } from './util/utils';
import Arithmetic from './util/arithmetic';
/**
* Calculate a interval of a minimum value and a maximum value
*
* @param {Number} min The minimum value
* @param {Number} max The maximum value
* @return {Array} An interval
*/
function getValidInterval(_ref) {
var _ref2 = _slicedToArray(_ref, 2),
min = _ref2[0],
max = _ref2[1];
var validMin = min,
validMax = max; // exchange
if (min > max) {
validMin = max;
validMax = min;
}
return [validMin, validMax];
}
/**
* Calculate the step which is easy to understand between ticks, like 10, 20, 25
*
* @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 {Decimal} The step which is easy to understand between two ticks
*/
function getFormatStep(roughStep, allowDecimals, correctionFactor) {
if (roughStep.lte(0)) {
return new Decimal(0);
}
var 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
var digitCountValue = new Decimal(10).pow(digitCount);
var stepRatio = roughStep.div(digitCountValue); // When an integer and a float multiplied, the accuracy of result may be wrong
var stepRatioScale = digitCount !== 1 ? 0.05 : 0.1;
var amendStepRatio = new Decimal(Math.ceil(stepRatio.div(stepRatioScale).toNumber())).add(correctionFactor).mul(stepRatioScale);
var formatStep = amendStepRatio.mul(digitCountValue);
return allowDecimals ? formatStep : new Decimal(Math.ceil(formatStep));
}
/**
* calculate the ticks when the minimum value equals to the maximum value
*
* @param {Number} value The minimum valuue which is also the maximum value
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @return {Array} ticks
*/
function getTickOfSingleValue(value, tickCount, allowDecimals) {
var step = 1; // calculate the middle value of ticks
var middle = new Decimal(value);
if (!middle.isint() && allowDecimals) {
var absVal = Math.abs(value);
if (absVal < 1) {
// The step should be a float number when the difference is smaller than 1
step = new Decimal(10).pow(Arithmetic.getDigitCount(value) - 1);
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 = new Decimal(Math.floor(value));
}
} else if (value === 0) {
middle = new Decimal(Math.floor((tickCount - 1) / 2));
} else if (!allowDecimals) {
middle = new Decimal(Math.floor(value));
}
var middleIndex = Math.floor((tickCount - 1) / 2);
var fn = compose(map(function (n) {
return middle.add(new Decimal(n - middleIndex).mul(step)).toNumber();
}), range);
return fn(0, tickCount);
}
/**
* Calculate the step
*
* @param {Number} min The minimum value of an interval
* @param {Number} max The maximum value of an interval
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @param {Number} correctionFactor A correction factor
* @return {Object} The step, minimum value of ticks, maximum value of ticks
*/
function calculateStep(min, max, tickCount, allowDecimals) {
var correctionFactor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 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
var step = getFormatStep(new Decimal(max).sub(min).div(tickCount - 1), allowDecimals, correctionFactor); // A medial value of ticks
var middle; // When 0 is inside the interval, 0 should be a tick
if (min <= 0 && max >= 0) {
middle = new Decimal(0);
} else {
// calculate the middle value
middle = new Decimal(min).add(max).div(2); // minus modulo value
middle = middle.sub(new Decimal(middle).mod(step));
}
var belowCount = Math.ceil(middle.sub(min).div(step).toNumber());
var upCount = Math.ceil(new Decimal(max).sub(middle).div(step).toNumber());
var scaleCount = belowCount + upCount + 1;
if (scaleCount > tickCount) {
// When more ticks need to cover the interval, step should be bigger.
return calculateStep(min, max, tickCount, allowDecimals, correctionFactor + 1);
}
if (scaleCount < tickCount) {
// When less ticks can cover the interval, we should add some additional ticks
upCount = max > 0 ? upCount + (tickCount - scaleCount) : upCount;
belowCount = max > 0 ? belowCount : belowCount + (tickCount - scaleCount);
}
return {
step: step,
tickMin: middle.sub(new Decimal(belowCount).mul(step)),
tickMax: middle.add(new Decimal(upCount).mul(step))
};
}
/**
* Calculate the ticks of an interval, the count of ticks will be guraranteed
*
* @param {Number} min, max min: The minimum value, max: The maximum value
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @return {Array} ticks
*/
function getNiceTickValuesFn(_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
min = _ref4[0],
max = _ref4[1];
var tickCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
var allowDecimals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
// More than two ticks should be return
var count = Math.max(tickCount, 2);
var _getValidInterval = getValidInterval([min, max]),
_getValidInterval2 = _slicedToArray(_getValidInterval, 2),
cormin = _getValidInterval2[0],
cormax = _getValidInterval2[1];
if (cormin === -Infinity || cormax === Infinity) {
var _values = cormax === Infinity ? [cormin].concat(_toConsumableArray(range(0, tickCount - 1).map(function () {
return Infinity;
}))) : [].concat(_toConsumableArray(range(0, tickCount - 1).map(function () {
return -Infinity;
})), [cormax]);
return min > max ? reverse(_values) : _values;
}
if (cormin === cormax) {
return getTickOfSingleValue(cormin, tickCount, allowDecimals);
} // Get the step between two ticks
var _calculateStep = calculateStep(cormin, cormax, count, allowDecimals),
step = _calculateStep.step,
tickMin = _calculateStep.tickMin,
tickMax = _calculateStep.tickMax;
var values = Arithmetic.rangeStep(tickMin, tickMax.add(new Decimal(0.1).mul(step)), step);
return min > max ? reverse(values) : values;
}
/**
* Calculate the ticks of an interval, the count of ticks won't be guraranteed
*
* @param {Number} min, max min: The minimum value, max: The maximum value
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @return {Array} ticks
*/
function getTickValuesFn(_ref5) {
var _ref6 = _slicedToArray(_ref5, 2),
min = _ref6[0],
max = _ref6[1];
var tickCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
var allowDecimals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
// More than two ticks should be return
var count = Math.max(tickCount, 2);
var _getValidInterval3 = getValidInterval([min, max]),
_getValidInterval4 = _slicedToArray(_getValidInterval3, 2),
cormin = _getValidInterval4[0],
cormax = _getValidInterval4[1];
if (cormin === -Infinity || cormax === Infinity) {
return [min, max];
}
if (cormin === cormax) {
return getTickOfSingleValue(cormin, tickCount, allowDecimals);
}
var step = getFormatStep(new Decimal(cormax).sub(cormin).div(count - 1), allowDecimals, 0);
var fn = compose(map(function (n) {
return new Decimal(cormin).add(new Decimal(n).mul(step)).toNumber();
}), range);
var values = fn(0, count).filter(function (entry) {
return entry >= cormin && entry <= cormax;
});
return min > max ? reverse(values) : values;
}
/**
* Calculate the ticks of an interval, the count of ticks won't be guraranteed,
* but the domain will be guaranteed
*
* @param {Number} min, max min: The minimum value, max: The maximum value
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @return {Array} ticks
*/
function getTickValuesFixedDomainFn(_ref7, tickCount) {
var _ref8 = _slicedToArray(_ref7, 2),
min = _ref8[0],
max = _ref8[1];
var allowDecimals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
// More than two ticks should be return
var _getValidInterval5 = getValidInterval([min, max]),
_getValidInterval6 = _slicedToArray(_getValidInterval5, 2),
cormin = _getValidInterval6[0],
cormax = _getValidInterval6[1];
if (cormin === -Infinity || cormax === Infinity) {
return [min, max];
}
if (cormin === cormax) {
return [cormin];
}
var count = Math.max(tickCount, 2);
var step = getFormatStep(new Decimal(cormax).sub(cormin).div(count - 1), allowDecimals, 0);
var values = [].concat(_toConsumableArray(Arithmetic.rangeStep(new Decimal(cormin), new Decimal(cormax).sub(new Decimal(0.99).mul(step)), step)), [cormax]);
return min > max ? reverse(values) : values;
}
export var getNiceTickValues = memoize(getNiceTickValuesFn);
export var getTickValues = memoize(getTickValuesFn);
export var getTickValuesFixedDomain = memoize(getTickValuesFixedDomainFn);

1
node_modules/recharts-scale/es6/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export { getTickValues, getNiceTickValues, getTickValuesFixedDomain } from './getNiceTickValues';

103
node_modules/recharts-scale/es6/util/arithmetic.js generated vendored Normal file
View File

@@ -0,0 +1,103 @@
/**
* @fileOverview 一些公用的运算方法
* @author xile611
* @date 2015-09-17
*/
import Decimal from 'decimal.js-light';
import { curry } from './utils';
/**
* 获取数值的位数
* 其中绝对值属于区间[0.1, 1) 得到的值为0
* 绝对值属于区间[0.01, 0.1),得到的位数为 -1
* 绝对值属于区间[0.001, 0.01),得到的位数为 -2
*
* @param {Number} value 数值
* @return {Integer} 位数
*/
function getDigitCount(value) {
var result;
if (value === 0) {
result = 1;
} else {
result = Math.floor(new Decimal(value).abs().log(10).toNumber()) + 1;
}
return result;
}
/**
* 按照固定的步长获取[start, end)这个区间的数据
* 并且需要处理js计算精度的问题
*
* @param {Decimal} start 起点
* @param {Decimal} end 终点,不包含该值
* @param {Decimal} step 步长
* @return {Array} 若干数值
*/
function rangeStep(start, end, step) {
var num = new Decimal(start);
var i = 0;
var result = []; // magic number to prevent infinite loop
while (num.lt(end) && i < 100000) {
result.push(num.toNumber());
num = num.add(step);
i++;
}
return result;
}
/**
* 对数值进行线性插值
*
* @param {Number} a 定义域的极点
* @param {Number} b 定义域的极点
* @param {Number} t [0, 1]内的某个值
* @return {Number} 定义域内的某个值
*/
var interpolateNumber = curry(function (a, b, t) {
var newA = +a;
var newB = +b;
return newA + t * (newB - newA);
});
/**
* 线性插值的逆运算
*
* @param {Number} a 定义域的极点
* @param {Number} b 定义域的极点
* @param {Number} x 可以认为是插值后的一个输出值
* @return {Number} 当x在 a ~ b这个范围内时返回值属于[0, 1]
*/
var uninterpolateNumber = curry(function (a, b, x) {
var diff = b - +a;
diff = diff || Infinity;
return (x - a) / diff;
});
/**
* 线性插值的逆运算,并且有截断的操作
*
* @param {Number} a 定义域的极点
* @param {Number} b 定义域的极点
* @param {Number} x 可以认为是插值后的一个输出值
* @return {Number} 当x在 a ~ b这个区间内时返回值属于[0, 1]
* 当x不在 a ~ b这个区间时会截断到 a ~ b 这个区间
*/
var uninterpolateTruncation = curry(function (a, b, x) {
var diff = b - +a;
diff = diff || Infinity;
return Math.max(0, Math.min(1, (x - a) / diff));
});
export default {
rangeStep: rangeStep,
getDigitCount: getDigitCount,
interpolateNumber: interpolateNumber,
uninterpolateNumber: uninterpolateNumber,
uninterpolateTruncation: uninterpolateTruncation
};

132
node_modules/recharts-scale/es6/util/utils.js generated vendored Normal file
View File

@@ -0,0 +1,132 @@
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var identity = function identity(i) {
return i;
};
export var PLACE_HOLDER = {
'@@functional/placeholder': true
};
var isPlaceHolder = function isPlaceHolder(val) {
return val === PLACE_HOLDER;
};
var curry0 = function curry0(fn) {
return function _curried() {
if (arguments.length === 0 || arguments.length === 1 && isPlaceHolder(arguments.length <= 0 ? undefined : arguments[0])) {
return _curried;
}
return fn.apply(void 0, arguments);
};
};
var curryN = function curryN(n, fn) {
if (n === 1) {
return fn;
}
return curry0(function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var argsLength = args.filter(function (arg) {
return arg !== PLACE_HOLDER;
}).length;
if (argsLength >= n) {
return fn.apply(void 0, args);
}
return curryN(n - argsLength, curry0(function () {
for (var _len2 = arguments.length, restArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
restArgs[_key2] = arguments[_key2];
}
var newArgs = args.map(function (arg) {
return isPlaceHolder(arg) ? restArgs.shift() : arg;
});
return fn.apply(void 0, _toConsumableArray(newArgs).concat(restArgs));
}));
});
};
export var curry = function curry(fn) {
return curryN(fn.length, fn);
};
export var range = function range(begin, end) {
var arr = [];
for (var i = begin; i < end; ++i) {
arr[i - begin] = i;
}
return arr;
};
export var map = curry(function (fn, arr) {
if (Array.isArray(arr)) {
return arr.map(fn);
}
return Object.keys(arr).map(function (key) {
return arr[key];
}).map(fn);
});
export var compose = function compose() {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
if (!args.length) {
return identity;
}
var fns = args.reverse(); // first function can receive multiply arguments
var firstFn = fns[0];
var tailsFn = fns.slice(1);
return function () {
return tailsFn.reduce(function (res, fn) {
return fn(res);
}, firstFn.apply(void 0, arguments));
};
};
export var reverse = function reverse(arr) {
if (Array.isArray(arr)) {
return arr.reverse();
} // can be string
return arr.split('').reverse.join('');
};
export var memoize = function memoize(fn) {
var lastArgs = null;
var lastResult = null;
return function () {
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
if (lastArgs && args.every(function (val, i) {
return val === lastArgs[i];
})) {
return lastResult;
}
lastArgs = args;
lastResult = fn.apply(void 0, args);
return lastResult;
};
};

317
node_modules/recharts-scale/lib/getNiceTickValues.js generated vendored Normal file
View File

@@ -0,0 +1,317 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getTickValuesFixedDomain = exports.getTickValues = exports.getNiceTickValues = void 0;
var _decimal = _interopRequireDefault(require("decimal.js-light"));
var _utils = require("./util/utils");
var _arithmetic = _interopRequireDefault(require("./util/arithmetic"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
/**
* Calculate a interval of a minimum value and a maximum value
*
* @param {Number} min The minimum value
* @param {Number} max The maximum value
* @return {Array} An interval
*/
function getValidInterval(_ref) {
var _ref2 = _slicedToArray(_ref, 2),
min = _ref2[0],
max = _ref2[1];
var validMin = min,
validMax = max; // exchange
if (min > max) {
validMin = max;
validMax = min;
}
return [validMin, validMax];
}
/**
* Calculate the step which is easy to understand between ticks, like 10, 20, 25
*
* @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 {Decimal} The step which is easy to understand between two ticks
*/
function getFormatStep(roughStep, allowDecimals, correctionFactor) {
if (roughStep.lte(0)) {
return new _decimal.default(0);
}
var digitCount = _arithmetic.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 digitCountValue = new _decimal.default(10).pow(digitCount);
var stepRatio = roughStep.div(digitCountValue); // When an integer and a float multiplied, the accuracy of result may be wrong
var stepRatioScale = digitCount !== 1 ? 0.05 : 0.1;
var amendStepRatio = new _decimal.default(Math.ceil(stepRatio.div(stepRatioScale).toNumber())).add(correctionFactor).mul(stepRatioScale);
var formatStep = amendStepRatio.mul(digitCountValue);
return allowDecimals ? formatStep : new _decimal.default(Math.ceil(formatStep));
}
/**
* calculate the ticks when the minimum value equals to the maximum value
*
* @param {Number} value The minimum valuue which is also the maximum value
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @return {Array} ticks
*/
function getTickOfSingleValue(value, tickCount, allowDecimals) {
var step = 1; // calculate the middle value of ticks
var middle = new _decimal.default(value);
if (!middle.isint() && allowDecimals) {
var absVal = Math.abs(value);
if (absVal < 1) {
// The step should be a float number when the difference is smaller than 1
step = new _decimal.default(10).pow(_arithmetic.default.getDigitCount(value) - 1);
middle = new _decimal.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 = new _decimal.default(Math.floor(value));
}
} else if (value === 0) {
middle = new _decimal.default(Math.floor((tickCount - 1) / 2));
} else if (!allowDecimals) {
middle = new _decimal.default(Math.floor(value));
}
var middleIndex = Math.floor((tickCount - 1) / 2);
var fn = (0, _utils.compose)((0, _utils.map)(function (n) {
return middle.add(new _decimal.default(n - middleIndex).mul(step)).toNumber();
}), _utils.range);
return fn(0, tickCount);
}
/**
* Calculate the step
*
* @param {Number} min The minimum value of an interval
* @param {Number} max The maximum value of an interval
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @param {Number} correctionFactor A correction factor
* @return {Object} The step, minimum value of ticks, maximum value of ticks
*/
function calculateStep(min, max, tickCount, allowDecimals) {
var correctionFactor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
// dirty hack (for recharts' test)
if (!Number.isFinite((max - min) / (tickCount - 1))) {
return {
step: new _decimal.default(0),
tickMin: new _decimal.default(0),
tickMax: new _decimal.default(0)
};
} // The step which is easy to understand between two ticks
var step = getFormatStep(new _decimal.default(max).sub(min).div(tickCount - 1), allowDecimals, correctionFactor); // A medial value of ticks
var middle; // When 0 is inside the interval, 0 should be a tick
if (min <= 0 && max >= 0) {
middle = new _decimal.default(0);
} else {
// calculate the middle value
middle = new _decimal.default(min).add(max).div(2); // minus modulo value
middle = middle.sub(new _decimal.default(middle).mod(step));
}
var belowCount = Math.ceil(middle.sub(min).div(step).toNumber());
var upCount = Math.ceil(new _decimal.default(max).sub(middle).div(step).toNumber());
var scaleCount = belowCount + upCount + 1;
if (scaleCount > tickCount) {
// When more ticks need to cover the interval, step should be bigger.
return calculateStep(min, max, tickCount, allowDecimals, correctionFactor + 1);
}
if (scaleCount < tickCount) {
// When less ticks can cover the interval, we should add some additional ticks
upCount = max > 0 ? upCount + (tickCount - scaleCount) : upCount;
belowCount = max > 0 ? belowCount : belowCount + (tickCount - scaleCount);
}
return {
step: step,
tickMin: middle.sub(new _decimal.default(belowCount).mul(step)),
tickMax: middle.add(new _decimal.default(upCount).mul(step))
};
}
/**
* Calculate the ticks of an interval, the count of ticks will be guraranteed
*
* @param {Number} min, max min: The minimum value, max: The maximum value
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @return {Array} ticks
*/
function getNiceTickValuesFn(_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
min = _ref4[0],
max = _ref4[1];
var tickCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
var allowDecimals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
// More than two ticks should be return
var count = Math.max(tickCount, 2);
var _getValidInterval = getValidInterval([min, max]),
_getValidInterval2 = _slicedToArray(_getValidInterval, 2),
cormin = _getValidInterval2[0],
cormax = _getValidInterval2[1];
if (cormin === -Infinity || cormax === Infinity) {
var _values = cormax === Infinity ? [cormin].concat(_toConsumableArray((0, _utils.range)(0, tickCount - 1).map(function () {
return Infinity;
}))) : [].concat(_toConsumableArray((0, _utils.range)(0, tickCount - 1).map(function () {
return -Infinity;
})), [cormax]);
return min > max ? (0, _utils.reverse)(_values) : _values;
}
if (cormin === cormax) {
return getTickOfSingleValue(cormin, tickCount, allowDecimals);
} // Get the step between two ticks
var _calculateStep = calculateStep(cormin, cormax, count, allowDecimals),
step = _calculateStep.step,
tickMin = _calculateStep.tickMin,
tickMax = _calculateStep.tickMax;
var values = _arithmetic.default.rangeStep(tickMin, tickMax.add(new _decimal.default(0.1).mul(step)), step);
return min > max ? (0, _utils.reverse)(values) : values;
}
/**
* Calculate the ticks of an interval, the count of ticks won't be guraranteed
*
* @param {Number} min, max min: The minimum value, max: The maximum value
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @return {Array} ticks
*/
function getTickValuesFn(_ref5) {
var _ref6 = _slicedToArray(_ref5, 2),
min = _ref6[0],
max = _ref6[1];
var tickCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
var allowDecimals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
// More than two ticks should be return
var count = Math.max(tickCount, 2);
var _getValidInterval3 = getValidInterval([min, max]),
_getValidInterval4 = _slicedToArray(_getValidInterval3, 2),
cormin = _getValidInterval4[0],
cormax = _getValidInterval4[1];
if (cormin === -Infinity || cormax === Infinity) {
return [min, max];
}
if (cormin === cormax) {
return getTickOfSingleValue(cormin, tickCount, allowDecimals);
}
var step = getFormatStep(new _decimal.default(cormax).sub(cormin).div(count - 1), allowDecimals, 0);
var fn = (0, _utils.compose)((0, _utils.map)(function (n) {
return new _decimal.default(cormin).add(new _decimal.default(n).mul(step)).toNumber();
}), _utils.range);
var values = fn(0, count).filter(function (entry) {
return entry >= cormin && entry <= cormax;
});
return min > max ? (0, _utils.reverse)(values) : values;
}
/**
* Calculate the ticks of an interval, the count of ticks won't be guraranteed,
* but the domain will be guaranteed
*
* @param {Number} min, max min: The minimum value, max: The maximum value
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @return {Array} ticks
*/
function getTickValuesFixedDomainFn(_ref7, tickCount) {
var _ref8 = _slicedToArray(_ref7, 2),
min = _ref8[0],
max = _ref8[1];
var allowDecimals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
// More than two ticks should be return
var _getValidInterval5 = getValidInterval([min, max]),
_getValidInterval6 = _slicedToArray(_getValidInterval5, 2),
cormin = _getValidInterval6[0],
cormax = _getValidInterval6[1];
if (cormin === -Infinity || cormax === Infinity) {
return [min, max];
}
if (cormin === cormax) {
return [cormin];
}
var count = Math.max(tickCount, 2);
var step = getFormatStep(new _decimal.default(cormax).sub(cormin).div(count - 1), allowDecimals, 0);
var values = [].concat(_toConsumableArray(_arithmetic.default.rangeStep(new _decimal.default(cormin), new _decimal.default(cormax).sub(new _decimal.default(0.99).mul(step)), step)), [cormax]);
return min > max ? (0, _utils.reverse)(values) : values;
}
var getNiceTickValues = (0, _utils.memoize)(getNiceTickValuesFn);
exports.getNiceTickValues = getNiceTickValues;
var getTickValues = (0, _utils.memoize)(getTickValuesFn);
exports.getTickValues = getTickValues;
var getTickValuesFixedDomain = (0, _utils.memoize)(getTickValuesFixedDomainFn);
exports.getTickValuesFixedDomain = getTickValuesFixedDomain;

25
node_modules/recharts-scale/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getTickValues", {
enumerable: true,
get: function get() {
return _getNiceTickValues.getTickValues;
}
});
Object.defineProperty(exports, "getNiceTickValues", {
enumerable: true,
get: function get() {
return _getNiceTickValues.getNiceTickValues;
}
});
Object.defineProperty(exports, "getTickValuesFixedDomain", {
enumerable: true,
get: function get() {
return _getNiceTickValues.getTickValuesFixedDomain;
}
});
var _getNiceTickValues = require("./getNiceTickValues");

115
node_modules/recharts-scale/lib/util/arithmetic.js generated vendored Normal file
View File

@@ -0,0 +1,115 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _decimal = _interopRequireDefault(require("decimal.js-light"));
var _utils = require("./utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @fileOverview 一些公用的运算方法
* @author xile611
* @date 2015-09-17
*/
/**
* 获取数值的位数
* 其中绝对值属于区间[0.1, 1) 得到的值为0
* 绝对值属于区间[0.01, 0.1),得到的位数为 -1
* 绝对值属于区间[0.001, 0.01),得到的位数为 -2
*
* @param {Number} value 数值
* @return {Integer} 位数
*/
function getDigitCount(value) {
var result;
if (value === 0) {
result = 1;
} else {
result = Math.floor(new _decimal.default(value).abs().log(10).toNumber()) + 1;
}
return result;
}
/**
* 按照固定的步长获取[start, end)这个区间的数据
* 并且需要处理js计算精度的问题
*
* @param {Decimal} start 起点
* @param {Decimal} end 终点,不包含该值
* @param {Decimal} step 步长
* @return {Array} 若干数值
*/
function rangeStep(start, end, step) {
var num = new _decimal.default(start);
var i = 0;
var result = []; // magic number to prevent infinite loop
while (num.lt(end) && i < 100000) {
result.push(num.toNumber());
num = num.add(step);
i++;
}
return result;
}
/**
* 对数值进行线性插值
*
* @param {Number} a 定义域的极点
* @param {Number} b 定义域的极点
* @param {Number} t [0, 1]内的某个值
* @return {Number} 定义域内的某个值
*/
var interpolateNumber = (0, _utils.curry)(function (a, b, t) {
var newA = +a;
var newB = +b;
return newA + t * (newB - newA);
});
/**
* 线性插值的逆运算
*
* @param {Number} a 定义域的极点
* @param {Number} b 定义域的极点
* @param {Number} x 可以认为是插值后的一个输出值
* @return {Number} 当x在 a ~ b这个范围内时返回值属于[0, 1]
*/
var uninterpolateNumber = (0, _utils.curry)(function (a, b, x) {
var diff = b - +a;
diff = diff || Infinity;
return (x - a) / diff;
});
/**
* 线性插值的逆运算,并且有截断的操作
*
* @param {Number} a 定义域的极点
* @param {Number} b 定义域的极点
* @param {Number} x 可以认为是插值后的一个输出值
* @return {Number} 当x在 a ~ b这个区间内时返回值属于[0, 1]
* 当x不在 a ~ b这个区间时会截断到 a ~ b 这个区间
*/
var uninterpolateTruncation = (0, _utils.curry)(function (a, b, x) {
var diff = b - +a;
diff = diff || Infinity;
return Math.max(0, Math.min(1, (x - a) / diff));
});
var _default = {
rangeStep: rangeStep,
getDigitCount: getDigitCount,
interpolateNumber: interpolateNumber,
uninterpolateNumber: uninterpolateNumber,
uninterpolateTruncation: uninterpolateTruncation
};
exports.default = _default;

155
node_modules/recharts-scale/lib/util/utils.js generated vendored Normal file
View File

@@ -0,0 +1,155 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.memoize = exports.reverse = exports.compose = exports.map = exports.range = exports.curry = exports.PLACE_HOLDER = void 0;
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var identity = function identity(i) {
return i;
};
var PLACE_HOLDER = {
'@@functional/placeholder': true
};
exports.PLACE_HOLDER = PLACE_HOLDER;
var isPlaceHolder = function isPlaceHolder(val) {
return val === PLACE_HOLDER;
};
var curry0 = function curry0(fn) {
return function _curried() {
if (arguments.length === 0 || arguments.length === 1 && isPlaceHolder(arguments.length <= 0 ? undefined : arguments[0])) {
return _curried;
}
return fn.apply(void 0, arguments);
};
};
var curryN = function curryN(n, fn) {
if (n === 1) {
return fn;
}
return curry0(function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var argsLength = args.filter(function (arg) {
return arg !== PLACE_HOLDER;
}).length;
if (argsLength >= n) {
return fn.apply(void 0, args);
}
return curryN(n - argsLength, curry0(function () {
for (var _len2 = arguments.length, restArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
restArgs[_key2] = arguments[_key2];
}
var newArgs = args.map(function (arg) {
return isPlaceHolder(arg) ? restArgs.shift() : arg;
});
return fn.apply(void 0, _toConsumableArray(newArgs).concat(restArgs));
}));
});
};
var curry = function curry(fn) {
return curryN(fn.length, fn);
};
exports.curry = curry;
var range = function range(begin, end) {
var arr = [];
for (var i = begin; i < end; ++i) {
arr[i - begin] = i;
}
return arr;
};
exports.range = range;
var map = curry(function (fn, arr) {
if (Array.isArray(arr)) {
return arr.map(fn);
}
return Object.keys(arr).map(function (key) {
return arr[key];
}).map(fn);
});
exports.map = map;
var compose = function compose() {
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
if (!args.length) {
return identity;
}
var fns = args.reverse(); // first function can receive multiply arguments
var firstFn = fns[0];
var tailsFn = fns.slice(1);
return function () {
return tailsFn.reduce(function (res, fn) {
return fn(res);
}, firstFn.apply(void 0, arguments));
};
};
exports.compose = compose;
var reverse = function reverse(arr) {
if (Array.isArray(arr)) {
return arr.reverse();
} // can be string
return arr.split('').reverse.join('');
};
exports.reverse = reverse;
var memoize = function memoize(fn) {
var lastArgs = null;
var lastResult = null;
return function () {
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}
if (lastArgs && args.every(function (val, i) {
return val === lastArgs[i];
})) {
return lastResult;
}
lastArgs = args;
lastResult = fn.apply(void 0, args);
return lastResult;
};
};
exports.memoize = memoize;

92
node_modules/recharts-scale/package.json generated vendored Normal file
View File

@@ -0,0 +1,92 @@
{
"name": "recharts-scale",
"version": "0.4.5",
"description": "Scale of Cartesian Coordinates",
"main": "lib/index",
"module": "es6/index.js",
"jsnext:main": "es6/index",
"keywords": [
"Scale",
"Cartesian Coordinates"
],
"files": [
"*.md",
"demo",
"es6",
"lib",
"umd",
"src"
],
"scripts": {
"build": "npm run build-cjs && npm run build-es6 && rimraf umd && npm run build-umd && npm run build-min",
"build-cjs": "rimraf lib && cross-env BABEL_ENV=commonjs babel ./src -d lib",
"build-es6": "rimraf es6 && cross-env babel ./src -d es6",
"build-umd": "cross-env NODE_ENV=development BABEL_ENV=commonjs webpack --entry ./src/index.js -o umd",
"build-min": "cross-env NODE_ENV=production BABEL_ENV=commonjs webpack --entry ./src/index.js -o umd",
"test": "nyc ava --verbose",
"autofix": "eslint src test --fix",
"lint": "eslint src test"
},
"pre-commit": [
"lint"
],
"repository": {
"type": "git",
"url": "https://github.com/recharts/recharts-scale.git"
},
"author": "recharts group",
"bugs": {
"url": "https://github.com/recharts/recharts-scale/issues"
},
"homepage": "https://github.com/recharts/recharts-scale",
"dependencies": {
"decimal.js-light": "^2.4.1"
},
"devDependencies": {
"@ava/babel": "^1.0.1",
"@babel/cli": "^7.1.0",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/register": "^7.0.0",
"ava": "^3.15.0",
"babel-eslint": "^10.0.0",
"babel-loader": "^8.0.0",
"cross-env": "^7.0.3",
"eslint": "^7.17.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.11.1",
"esm": "^3.2.25",
"nyc": "^15.1.0",
"pre-commit": "^1.1.3",
"webpack": "^5.15.0",
"webpack-cli": "^4.3.1"
},
"ava": {
"files": [
"test/**/*.test.js"
],
"ignoredByWatcher": [
"umd/**/*"
],
"failFast": true,
"tap": true,
"require": [
"esm",
"@babel/register"
],
"babel": {
"testOptions": {
"presets": [
"@babel/preset-env"
]
}
}
},
"license": "MIT"
}

260
node_modules/recharts-scale/src/getNiceTickValues.js generated vendored Normal file
View File

@@ -0,0 +1,260 @@
/**
* @fileOverview calculate tick values of scale
* @author xile611, arcthur
* @date 2015-09-17
*/
import Decimal from 'decimal.js-light';
import {
compose, range, memoize, map, reverse,
} from './util/utils';
import Arithmetic from './util/arithmetic';
/**
* Calculate a interval of a minimum value and a maximum value
*
* @param {Number} min The minimum value
* @param {Number} max The maximum value
* @return {Array} An interval
*/
function getValidInterval([min, max]) {
let [validMin, validMax] = [min, max];
// exchange
if (min > max) {
[validMin, validMax] = [max, min];
}
return [validMin, validMax];
}
/**
* Calculate the step which is easy to understand between ticks, like 10, 20, 25
*
* @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 {Decimal} The step which is easy to understand between two ticks
*/
function getFormatStep(roughStep, allowDecimals, correctionFactor) {
if (roughStep.lte(0)) { return new Decimal(0); }
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 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 stepRatioScale = digitCount !== 1 ? 0.05 : 0.1;
const amendStepRatio = new Decimal(
Math.ceil(stepRatio.div(stepRatioScale).toNumber()),
).add(correctionFactor).mul(stepRatioScale);
const formatStep = amendStepRatio.mul(digitCountValue);
return allowDecimals ? formatStep : new Decimal(Math.ceil(formatStep));
}
/**
* calculate the ticks when the minimum value equals to the maximum value
*
* @param {Number} value The minimum valuue which is also the maximum value
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @return {Array} ticks
*/
function getTickOfSingleValue(value, tickCount, allowDecimals) {
let step = 1;
// calculate the middle value of ticks
let middle = new Decimal(value);
if (!middle.isint() && allowDecimals) {
const absVal = Math.abs(value);
if (absVal < 1) {
// The step should be a float number when the difference is smaller than 1
step = new Decimal(10).pow(Arithmetic.getDigitCount(value) - 1);
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 = new Decimal(Math.floor(value));
}
} else if (value === 0) {
middle = new Decimal(Math.floor((tickCount - 1) / 2));
} else if (!allowDecimals) {
middle = new Decimal(Math.floor(value));
}
const middleIndex = Math.floor((tickCount - 1) / 2);
const fn = compose(
map((n) => middle.add(new Decimal(n - middleIndex).mul(step)).toNumber()),
range,
);
return fn(0, tickCount);
}
/**
* Calculate the step
*
* @param {Number} min The minimum value of an interval
* @param {Number} max The maximum value of an interval
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @param {Number} correctionFactor A correction factor
* @return {Object} The step, minimum value of ticks, maximum value of ticks
*/
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(
new Decimal(max).sub(min).div(tickCount - 1),
allowDecimals,
correctionFactor,
);
// A medial value of ticks
let middle;
// When 0 is inside the interval, 0 should be a tick
if (min <= 0 && max >= 0) {
middle = new Decimal(0);
} else {
// calculate the middle value
middle = new Decimal(min).add(max).div(2);
// minus modulo value
middle = middle.sub(new Decimal(middle).mod(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;
if (scaleCount > tickCount) {
// When more ticks need to cover the interval, step should be bigger.
return calculateStep(min, max, tickCount, allowDecimals, correctionFactor + 1);
} if (scaleCount < tickCount) {
// When less ticks can cover the interval, we should add some additional ticks
upCount = max > 0 ? upCount + (tickCount - scaleCount) : upCount;
belowCount = max > 0 ? belowCount : belowCount + (tickCount - scaleCount);
}
return {
step,
tickMin: middle.sub(new Decimal(belowCount).mul(step)),
tickMax: middle.add(new Decimal(upCount).mul(step)),
};
}
/**
* Calculate the ticks of an interval, the count of ticks will be guraranteed
*
* @param {Number} min, max min: The minimum value, max: The maximum value
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @return {Array} ticks
*/
function getNiceTickValuesFn([min, max], tickCount = 6, allowDecimals = true) {
// More than two ticks should be return
const count = Math.max(tickCount, 2);
const [cormin, cormax] = getValidInterval([min, max]);
if (cormin === -Infinity || cormax === Infinity) {
const values = cormax === Infinity
? [cormin, ...range(0, tickCount - 1).map(() => Infinity)]
: [...range(0, tickCount - 1).map(() => -Infinity), cormax];
return min > max ? reverse(values) : values;
}
if (cormin === cormax) {
return getTickOfSingleValue(cormin, tickCount, allowDecimals);
}
// Get the step between two ticks
const { step, tickMin, tickMax } = calculateStep(cormin, cormax, count, allowDecimals);
const values = Arithmetic.rangeStep(tickMin, tickMax.add(new Decimal(0.1).mul(step)), step);
return min > max ? reverse(values) : values;
}
/**
* Calculate the ticks of an interval, the count of ticks won't be guraranteed
*
* @param {Number} min, max min: The minimum value, max: The maximum value
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @return {Array} ticks
*/
function getTickValuesFn([min, max], tickCount = 6, allowDecimals = true) {
// More than two ticks should be return
const count = Math.max(tickCount, 2);
const [cormin, cormax] = getValidInterval([min, max]);
if (cormin === -Infinity || cormax === Infinity) {
return [min, max];
}
if (cormin === cormax) {
return getTickOfSingleValue(cormin, tickCount, allowDecimals);
}
const step = getFormatStep(new Decimal(cormax).sub(cormin).div(count - 1), allowDecimals, 0);
const fn = compose(
map((n) => new Decimal(cormin).add(new Decimal(n).mul(step)).toNumber()),
range,
);
const values = fn(0, count).filter((entry) => (entry >= cormin && entry <= cormax));
return min > max ? reverse(values) : values;
}
/**
* Calculate the ticks of an interval, the count of ticks won't be guraranteed,
* but the domain will be guaranteed
*
* @param {Number} min, max min: The minimum value, max: The maximum value
* @param {Integer} tickCount The count of ticks
* @param {Boolean} allowDecimals Allow the ticks to be decimals or not
* @return {Array} ticks
*/
function getTickValuesFixedDomainFn([min, max], tickCount, allowDecimals = true) {
// More than two ticks should be return
const [cormin, cormax] = getValidInterval([min, max]);
if (cormin === -Infinity || cormax === Infinity) {
return [min, max];
}
if (cormin === cormax) { return [cormin]; }
const count = Math.max(tickCount, 2);
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,
];
return min > max ? reverse(values) : values;
}
export const getNiceTickValues = memoize(getNiceTickValuesFn);
export const getTickValues = memoize(getTickValuesFn);
export const getTickValuesFixedDomain = memoize(getTickValuesFixedDomainFn);

1
node_modules/recharts-scale/src/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export { getTickValues, getNiceTickValues, getTickValuesFixedDomain } from './getNiceTickValues';

108
node_modules/recharts-scale/src/util/arithmetic.js generated vendored Normal file
View File

@@ -0,0 +1,108 @@
/**
* @fileOverview 一些公用的运算方法
* @author xile611
* @date 2015-09-17
*/
import Decimal from 'decimal.js-light';
import { curry } from './utils';
/**
* 获取数值的位数
* 其中绝对值属于区间[0.1, 1) 得到的值为0
* 绝对值属于区间[0.01, 0.1),得到的位数为 -1
* 绝对值属于区间[0.001, 0.01),得到的位数为 -2
*
* @param {Number} value 数值
* @return {Integer} 位数
*/
function getDigitCount(value) {
let result;
if (value === 0) {
result = 1;
} else {
result = Math.floor(new Decimal(value).abs().log(10)
.toNumber()) + 1;
}
return result;
}
/**
* 按照固定的步长获取[start, end)这个区间的数据
* 并且需要处理js计算精度的问题
*
* @param {Decimal} start 起点
* @param {Decimal} end 终点,不包含该值
* @param {Decimal} step 步长
* @return {Array} 若干数值
*/
function rangeStep(start, end, step) {
let num = new Decimal(start);
let i = 0;
const result = [];
// magic number to prevent infinite loop
while (num.lt(end) && i < 100000) {
result.push(num.toNumber());
num = num.add(step);
i++;
}
return result;
}
/**
* 对数值进行线性插值
*
* @param {Number} a 定义域的极点
* @param {Number} b 定义域的极点
* @param {Number} t [0, 1]内的某个值
* @return {Number} 定义域内的某个值
*/
const interpolateNumber = curry((a, b, t) => {
const newA = +a;
const newB = +b;
return newA + t * (newB - newA);
});
/**
* 线性插值的逆运算
*
* @param {Number} a 定义域的极点
* @param {Number} b 定义域的极点
* @param {Number} x 可以认为是插值后的一个输出值
* @return {Number} 当x在 a ~ b这个范围内时返回值属于[0, 1]
*/
const uninterpolateNumber = curry((a, b, x) => {
let diff = b - (+a);
diff = diff || Infinity;
return (x - a) / diff;
});
/**
* 线性插值的逆运算,并且有截断的操作
*
* @param {Number} a 定义域的极点
* @param {Number} b 定义域的极点
* @param {Number} x 可以认为是插值后的一个输出值
* @return {Number} 当x在 a ~ b这个区间内时返回值属于[0, 1]
* 当x不在 a ~ b这个区间时会截断到 a ~ b 这个区间
*/
const uninterpolateTruncation = curry((a, b, x) => {
let diff = b - (+a);
diff = diff || Infinity;
return Math.max(0, Math.min(1, (x - a) / diff));
});
export default {
rangeStep,
getDigitCount,
interpolateNumber,
uninterpolateNumber,
uninterpolateTruncation,
};

94
node_modules/recharts-scale/src/util/utils.js generated vendored Normal file
View File

@@ -0,0 +1,94 @@
const identity = (i) => i;
export const PLACE_HOLDER = {
'@@functional/placeholder': true,
};
const isPlaceHolder = (val) => val === PLACE_HOLDER;
const curry0 = (fn) => function _curried(...args) {
if (args.length === 0 || args.length === 1 && isPlaceHolder(args[0])) {
return _curried;
}
return fn(...args);
};
const curryN = (n, fn) => {
if (n === 1) {
return fn;
}
return curry0((...args) => {
const argsLength = args.filter((arg) => arg !== PLACE_HOLDER).length;
if (argsLength >= n) {
return fn(...args);
}
return curryN(n - argsLength, curry0((...restArgs) => {
const newArgs = args.map((arg) => (isPlaceHolder(arg) ? restArgs.shift() : arg));
return fn(...newArgs, ...restArgs);
}));
});
};
export const curry = (fn) => curryN(fn.length, fn);
export const range = (begin, end) => {
const arr = [];
for (let i = begin; i < end; ++i) {
arr[i - begin] = i;
}
return arr;
};
export const map = curry((fn, arr) => {
if (Array.isArray(arr)) {
return arr.map(fn);
}
return Object.keys(arr).map((key) => arr[key]).map(fn);
});
export const compose = (...args) => {
if (!args.length) {
return identity;
}
const fns = args.reverse();
// first function can receive multiply arguments
const firstFn = fns[0];
const tailsFn = fns.slice(1);
return (...composeArgs) => tailsFn.reduce((res, fn) => fn(res),
firstFn(...composeArgs));
};
export const reverse = (arr) => {
if (Array.isArray(arr)) {
return arr.reverse();
}
// can be string
return arr.split('').reverse.join('');
};
export const memoize = (fn) => {
let lastArgs = null;
let lastResult = null;
return (...args) => {
if (lastArgs && args.every((val, i) => val === lastArgs[i])) {
return lastResult;
}
lastArgs = args;
lastResult = fn(...args);
return lastResult;
};
};

97
node_modules/recharts-scale/umd/RechartsScale.js generated vendored Normal file

File diff suppressed because one or more lines are too long

2
node_modules/recharts-scale/umd/RechartsScale.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
/*! decimal.js-light v2.5.1 https://github.com/MikeMcl/decimal.js-light/LICENCE */