Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const withinBound = (value, bound) => {
return value >= Collection.getMinValue(bound) && value <= Collection.getMaxValue(bound);
};
const ensureZero = (domain) => {
const isDependent = (axis === "y" && !horizontal) || (axis === "x" && horizontal);
return isDependent ?
[Collection.getMinValue(domain, 0), Collection.getMaxValue(domain, 0)] : domain;
};
const datasets = this.getDataFromChildren(props);
const getDefaultMin = (axis) => {
const defaultZero = Scale.getType(props.scale[axis]) === "log"
? 1 / Number.MAX_SAFE_INTEGER
: 0;
let defaultMin = defaultZero;
const minY = Collection.getMinValue(props.domain[axis]);
const maxY = Collection.getMaxValue(props.domain[axis]);
if (minY < 0 && maxY <= 0) {
defaultMin = maxY;
} else if (minY >= 0 && maxY > 0) {
defaultMin = minY;
}
return datum[`_${axis}`] instanceof Date ? new Date(defaultMin) : defaultMin;
};
const _y0 = datum._y0 !== undefined ? datum._y0 : getDefaultMin("y");
scale: (currentDomain, originalDomain, factor) => {
const [fromBound, toBound] = originalDomain;
const [from, to] = currentDomain;
const range = Math.abs(from - to);
const midpoint = +from + (range / 2);
const newRange = (range * factor) / 2;
return [
Collection.getMaxValue([midpoint - newRange, fromBound]),
Collection.getMinValue([midpoint + newRange, toBound])
];
},
const makeBound = (a, b) => {
return [ Collection.getMinValue([a, b]), Collection.getMaxValue([a, b]) ]
};
const getDefaultMin = (axis) => {
const defaultZero = Scale.getType(scale[axis]) === "log"
? 1 / Number.MAX_SAFE_INTEGER
: 0;
const domain = scale[axis].domain();
const minY = Collection.getMinValue(domain);
const maxY = Collection.getMaxValue(domain);
let defaultMin = defaultZero;
if (minY < 0 && maxY <= 0) {
defaultMin = maxY;
} else if (minY >= 0 && maxY > 0) {
defaultMin = minY;
}
return Collection.containsDates(domain) ? new Date(defaultMin) : defaultMin;
}
const childDomain = child.props && child.type.getDomain(sharedProps, currentAxis);
if (childDomain) {
const childDomainLength = childDomain.length;
for (let index = 0; index < childDomainLength; index++) {
childDomains[childDomainsLength++] = childDomain[index];
}
}
} else if (child.props && child.props.children) {
const newChildren = React.Children.toArray(child.props.children);
const newChildrenLength = newChildren.length;
for (let index = 0; index < newChildrenLength; index++) {
children[childrenLength++] = newChildren[index];
}
}
}
const min = Collection.getMinValue(childDomains);
const max = Collection.getMaxValue(childDomains);
return childDomains.length === 0 ?
[0, 1] : [min, max];
},