packages/victory-core/src/victory-util/domain.js
function padDomain(domain, props, axis) {
  if (!props.domainPadding) {
    return domain;
  }

  const minDomain = getMinFromProps(props, axis);
  const maxDomain = getMaxFromProps(props, axis);
  const padding = getDomainPadding(props, axis);
  if (!padding.left && !padding.right) {
    return domain;
  }

  const min = Collection.getMinValue(domain);
  const max = Collection.getMaxValue(domain);
  const currentAxis = Helpers.getCurrentAxis(axis, props.horizontal);
  const range = Helpers.getRange(props, currentAxis);
  const rangeExtent = Math.abs(range[0] - range[1]);

  // Naive initial padding calculation
  const initialPadding = {
    left: (Math.abs(max - min) * padding.left) / rangeExtent,
    right: (Math.abs(max - min) * padding.right) / rangeExtent
  };

  const singleQuadrantDomainPadding = isPlainObject(props.singleQuadrantDomainPadding)
    ? props.singleQuadrantDomainPadding[axis]
    : props.singleQuadrantDomainPadding;

  const adjust = (val, type) => {
    if (singleQuadrantDomainPadding === false) {
      return val;
    }
    const coerce =
      (type === "min" && min >= 0 && val <= 0) || (type === "max" && max <= 0 && val >= 0);
    return coerce ? 0 : val;
  };

  // Adjust the domain by the initial padding
  const adjustedDomain = {
    min: adjust(min.valueOf() - initialPadding.left, "min"),
    max: adjust(max.valueOf() + initialPadding.right, "max")
  };

  // re-calculate padding, taking the adjusted domain into account
  const finalPadding = {
    left: (Math.abs(adjustedDomain.max - adjustedDomain.min) * padding.left) / rangeExtent,
    right: (Math.abs(adjustedDomain.max - adjustedDomain.min) * padding.right) / rangeExtent
  };

  // Adjust the domain by the final padding
  const paddedDomain = {
    min: adjust(min.valueOf() - finalPadding.left, "min"),
    max: adjust(max.valueOf() + finalPadding.right, "max")
  };

  // default to minDomain / maxDomain if they exist
  const finalDomain = {
    min: minDomain !== undefined ? minDomain : paddedDomain.min,
    max: maxDomain !== undefined ? maxDomain : paddedDomain.max
  };

  return min instanceof Date || max instanceof Date
    ? getDomainFromMinMax(new Date(finalDomain.min), new Date(finalDomain.max))
    : getDomainFromMinMax(finalDomain.min, finalDomain.max);
}
function padDomain(domain, props, axis) {
  if (!props.domainPadding) {
    return domain;
  }

  const minDomain = getMinFromProps(props, axis);
  const maxDomain = getMaxFromProps(props, axis);
  const padding = getDomainPadding(props, axis);
  if (!padding.left && !padding.right) {
    return domain;
  }

  const min = Collection.getMinValue(domain);
  const max = Collection.getMaxValue(domain);
  const currentAxis = Helpers.getCurrentAxis(axis, props.horizontal);
  const range = Helpers.getRange(props, currentAxis);
  const rangeExtent = Math.abs(range[0] - range[1]);

  // Naive initial padding calculation
  const initialPadding = {
    left: (Math.abs(max - min) * padding.left) / rangeExtent,
    right: (Math.abs(max - min) * padding.right) / rangeExtent
  };

  const singleQuadrantDomainPadding = isPlainObject(props.singleQuadrantDomainPadding)
    ? props.singleQuadrantDomainPadding[axis]
    : props.singleQuadrantDomainPadding;

  const adjust = (val, type) => {
    if (singleQuadrantDomainPadding === false) {
      return val;
    }
    const coerce =
      (type === "min" && min >= 0 && val <= 0) || (type === "max" && max <= 0 && val >= 0);
    return coerce ? 0 : val;
  };

  // Adjust the domain by the initial padding
  const adjustedDomain = {
    min: adjust(min.valueOf() - initialPadding.left, "min"),
    max: adjust(max.valueOf() + initialPadding.right, "max")
  };

  // re-calculate padding, taking the adjusted domain into account
  const finalPadding = {
    left: (Math.abs(adjustedDomain.max - adjustedDomain.min) * padding.left) / rangeExtent,
    right: (Math.abs(adjustedDomain.max - adjustedDomain.min) * padding.right) / rangeExtent
  };

  // Adjust the domain by the final padding
  const paddedDomain = {
    min: adjust(min.valueOf() - finalPadding.left, "min"),
    max: adjust(max.valueOf() + finalPadding.right, "max")
  };

  // default to minDomain / maxDomain if they exist
  const finalDomain = {
    min: minDomain !== undefined ? minDomain : paddedDomain.min,
    max: maxDomain !== undefined ? maxDomain : paddedDomain.max
  };

  return min instanceof Date || max instanceof Date
    ? getDomainFromMinMax(new Date(finalDomain.min), new Date(finalDomain.max))
    : getDomainFromMinMax(finalDomain.min, finalDomain.max);
}
function padDomain ( domain , props , axis ) { if ( ! props . domainPadding ) { return domain ; } const minDomain = getMinFromProps ( props , axis ) ; const maxDomain = getMaxFromProps ( props , axis ) ; const padding = getDomainPadding ( props , axis ) ; if ( ! padding . left && ! padding . right ) { return domain ; } const min = Collection . getMinValue ( domain ) ; const max = Collection . getMaxValue ( domain ) ; const currentAxis = Helpers . getCurrentAxis ( axis , props . horizontal ) ; const range = Helpers . getRange ( props , currentAxis ) ; const rangeExtent = Math . abs ( range [ 0 ] - range [ 1 ] ) ; // Naive initial padding calculation const initialPadding = { left : ( Math . abs ( max - min ) * padding . left ) / rangeExtent , right : ( Math . abs ( max - min ) * padding . right ) / rangeExtent } ; const singleQuadrantDomainPadding = isPlainObject ( props . singleQuadrantDomainPadding ) ? props . singleQuadrantDomainPadding [ axis ] : props . singleQuadrantDomainPadding ; const adjust = ( val , type ) => { if ( singleQuadrantDomainPadding === false ) { return val ; } const coerce = ( type === "min" && min >= 0 && val <= 0 ) || ( type === "max" && max <= 0 && val >= 0 ) ; return coerce ? 0 : val ; } ; // Adjust the domain by the initial padding const adjustedDomain = { min : adjust ( min . valueOf ( ) - initialPadding . left , "min" ) , max : adjust ( max . valueOf ( ) + initialPadding . right , "max" ) } ; // re-calculate padding, taking the adjusted domain into account const finalPadding = { left : ( Math . abs ( adjustedDomain . max - adjustedDomain . min ) * padding . left ) / rangeExtent , right : ( Math . abs ( adjustedDomain . max - adjustedDomain . min ) * padding . right ) / rangeExtent } ; // Adjust the domain by the final padding const paddedDomain = { min : adjust ( min . valueOf ( ) - finalPadding . left , "min" ) , max : adjust ( max . valueOf ( ) + finalPadding . right , "max" ) } ; // default to minDomain / maxDomain if they exist const finalDomain = { min : minDomain !== undefined ? minDomain : paddedDomain . min , max : maxDomain !== undefined ? maxDomain : paddedDomain . max } ; return min instanceof Date || max instanceof Date ? getDomainFromMinMax ( new Date ( finalDomain . min ) , new Date ( finalDomain . max ) ) : getDomainFromMinMax ( finalDomain . min , finalDomain . max ) ; }
eslint-disable-next-line max-statements
eslint - disable - next - line max - statements