NuclearDispersionSystem/ant-design-vue-jeecg/node_modules/@antv/util/lib/array/get-range.js
2023-09-14 14:47:11 +08:00

31 lines
669 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var filter = require('../filter');
var isArray = require('../type/is-array');
var getRange = function getRange(values) {
// 存在 NaN 时min,max 判定会出问题
values = filter(values, function (v) {
return !isNaN(v);
});
if (!values.length) {
// 如果没有数值则直接返回0
return {
min: 0,
max: 0
};
}
if (isArray(values[0])) {
var tmp = [];
for (var i = 0; i < values.length; i++) {
tmp = tmp.concat(values[i]);
}
values = tmp;
}
var max = Math.max.apply(null, values);
var min = Math.min.apply(null, values);
return {
min: min,
max: max
};
};
module.exports = getRange;