How to use the victory-core.Collection.getMaxValue function in victory-core

To help you get started, we’ve selected a few victory-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FormidableLabs / victory / packages / victory-area / src / helper-methods.js View on Github external
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;
  }
github FormidableLabs / victory / packages / victory-brush-line / src / victory-brush-line.js View on Github external
const getBrushDomain = (brushDomain, fullDomain) => {
  if (brushDomain) {
    const brushMin = Collection.getMinValue(brushDomain);
    const brushMax = Collection.getMaxValue(brushDomain);
    const domainMin = Collection.getMinValue(fullDomain);
    const domainMax = Collection.getMaxValue(fullDomain);
    const defaultMin = brushMin < domainMin ? domainMin : domainMax - SMALL_NUMBER;
    const defaultMax = brushMax > domainMax ? domainMax : domainMin + SMALL_NUMBER;
    const min = withinBound(brushMin, fullDomain) ? brushMin : defaultMin;
    const max = withinBound(brushMax, fullDomain) ? brushMax : defaultMax;
    return [min, max];
  }
  return fullDomain;
};
github FormidableLabs / victory / packages / victory-brush-line / src / victory-brush-line.js View on Github external
const getBrushDomain = (brushDomain, fullDomain) => {
  if (brushDomain) {
    const brushMin = Collection.getMinValue(brushDomain);
    const brushMax = Collection.getMaxValue(brushDomain);
    const domainMin = Collection.getMinValue(fullDomain);
    const domainMax = Collection.getMaxValue(fullDomain);
    const defaultMin = brushMin < domainMin ? domainMin : domainMax - SMALL_NUMBER;
    const defaultMax = brushMax > domainMax ? domainMax : domainMin + SMALL_NUMBER;
    const min = withinBound(brushMin, fullDomain) ? brushMin : defaultMin;
    const max = withinBound(brushMax, fullDomain) ? brushMax : defaultMax;
    return [min, max];
  }
  return fullDomain;
};
github FormidableLabs / victory / packages / victory-bar / src / helper-methods.js View on Github external
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");
github FormidableLabs / victory / packages / victory-brush-line / src / victory-brush-line.js View on Github external
renderHandles(props) {
    const { handleComponent, handleStyle, id, brushDomain, datum = {}, activeBrushes = {} } = props;
    if (!brushDomain) {
      return null;
    }
    const handleDimensions = this.getHandleDimensions(props);
    const style = assign({}, fallbackProps.handleStyle, handleStyle);
    const minDatum = assign({ handleValue: Collection.getMinValue(brushDomain) }, datum);
    const maxDatum = assign({ handleValue: Collection.getMaxValue(brushDomain) }, datum);
    const minHandleProps = assign(
      {
        key: `${id}-min`,
        style: Helpers.evaluateStyle(style, minDatum, activeBrushes.minHandle)
      },
      handleDimensions.min
    );
    const maxHandleProps = assign(
      {
        key: `${id}-max`,
        style: Helpers.evaluateStyle(style, maxDatum, activeBrushes.maxHandle)
      },
      handleDimensions.max
    );
    return [
      React.cloneElement(handleComponent, minHandleProps),
github FormidableLabs / victory / src / components / containers / helper-methods.js View on Github external
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])
    ];
  },