victory-native
Version:
A charting library for React Native with a focus on performance and customization.
23 lines (22 loc) • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getYScaleInputBounds = void 0;
const getYScaleInputBounds = ({ data, yKeys, domain, tickDomain, }) => {
var _a, _b, _c, _d;
const yMin = (_b = (_a = domain === null || domain === void 0 ? void 0 : domain[0]) !== null && _a !== void 0 ? _a : tickDomain === null || tickDomain === void 0 ? void 0 : tickDomain[0]) !== null && _b !== void 0 ? _b : Math.min(...yKeys.map((key) => {
return data.reduce((min, curr) => {
if (typeof curr[key] !== "number")
return min;
return Math.min(min, curr[key]);
}, Infinity);
}));
const yMax = (_d = (_c = domain === null || domain === void 0 ? void 0 : domain[1]) !== null && _c !== void 0 ? _c : tickDomain === null || tickDomain === void 0 ? void 0 : tickDomain[1]) !== null && _d !== void 0 ? _d : Math.max(...yKeys.map((key) => {
return data.reduce((max, curr) => {
if (typeof curr[key] !== "number")
return max;
return Math.max(max, curr[key]);
}, -Infinity);
}));
return { yMin, yMax };
};
exports.getYScaleInputBounds = getYScaleInputBounds;