How to use the victory-core.Helpers.evaluateProp 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-tooltip / src / victory-tooltip.js View on Github external
const defaultDy = horizontal ? 0 : padding;

    return assign({}, props, {
      active,
      text,
      style,
      flyoutStyle,
      orientation,
      flyoutHeight,
      flyoutWidth,
      centerOffset: { x: offsetX, y: offsetY },
      dx: dx !== undefined ? Helpers.evaluateProp(dx, evaluatedProps) : defaultDx,
      dy: dy !== undefined ? Helpers.evaluateProp(dy, evaluatedProps) : defaultDy,
      cornerRadius: Helpers.evaluateProp(cornerRadius, evaluatedProps),
      pointerLength: Helpers.evaluateProp(pointerLength, evaluatedProps),
      pointerWidth: Helpers.evaluateProp(pointerWidth, evaluatedProps)
    });
  }
github FormidableLabs / victory / packages / victory-tooltip / src / victory-tooltip.js View on Github external
text,
      style,
      flyoutStyle,
      orientation,
      flyoutHeight,
      flyoutWidth
    });

    const offsetX =
      isPlainObject(centerOffset) && centerOffset.x !== undefined
        ? Helpers.evaluateProp(centerOffset.x, evaluatedProps)
        : 0;

    const offsetY =
      isPlainObject(centerOffset) && centerOffset.y !== undefined
        ? Helpers.evaluateProp(centerOffset.y, evaluatedProps)
        : 0;

    const padding = (flyoutStyle && flyoutStyle.padding) || 0;
    const defaultDx = horizontal ? padding : 0;
    const defaultDy = horizontal ? 0 : padding;

    return assign({}, props, {
      active,
      text,
      style,
      flyoutStyle,
      orientation,
      flyoutHeight,
      flyoutWidth,
      centerOffset: { x: offsetX, y: offsetY },
      dx: dx !== undefined ? Helpers.evaluateProp(dx, evaluatedProps) : defaultDx,
github patternfly / patternfly-react / packages / patternfly-4 / react-charts / src / components / ChartPoint / ChartPoint.js View on Github external
const size = Helpers.evaluateProp(props.size, datum, active);
    if (props.getPath) {
      return props.getPath(x, y, size);
    }
    const pathFunctions = {
      circle: pathHelpers.circle,
      square: pathHelpers.square,
      diamond: pathHelpers.diamond,
      triangleDown: pathHelpers.triangleDown,
      triangleUp: pathHelpers.triangleUp,
      plus: pathHelpers.plus,
      minus: pathHelpers.minus,
      star: pathHelpers.star,
      dash: pathHelpers.dash
    };
    const symbol = Helpers.evaluateProp(props.symbol, datum, active);
    const symbolFunction = typeof pathFunctions[symbol] === 'function' ? pathFunctions[symbol] : pathFunctions.circle;
    return symbolFunction(x, y, size);
  };
}
github FormidableLabs / victory / packages / victory-pie / src / slice.js View on Github external
const getPath = (props) => {
  const { slice, radius, innerRadius } = props;
  if (isFunction(props.pathFunction)) {
    return props.pathFunction(slice);
  }
  const cornerRadius = Helpers.evaluateProp(props.cornerRadius, props);
  const padAngle = Helpers.degreesToRadians(Helpers.evaluateProp(props.padAngle, props));
  const startAngle = Helpers.degreesToRadians(Helpers.evaluateProp(props.sliceStartAngle, props));
  const endAngle = Helpers.degreesToRadians(Helpers.evaluateProp(props.sliceEndAngle, props));
  const pathFunction = d3Shape
    .arc()
    .cornerRadius(cornerRadius)
    .outerRadius(radius)
    .innerRadius(innerRadius);
  return pathFunction(defaults({ startAngle, endAngle, padAngle }, slice));
};
github FormidableLabs / victory / packages / victory-pie / src / slice.js View on Github external
const getPath = (props) => {
  const { slice, radius, innerRadius } = props;
  if (isFunction(props.pathFunction)) {
    return props.pathFunction(slice);
  }
  const cornerRadius = Helpers.evaluateProp(props.cornerRadius, props);
  const padAngle = Helpers.degreesToRadians(Helpers.evaluateProp(props.padAngle, props));
  const startAngle = Helpers.degreesToRadians(Helpers.evaluateProp(props.sliceStartAngle, props));
  const endAngle = Helpers.degreesToRadians(Helpers.evaluateProp(props.sliceEndAngle, props));
  const pathFunction = d3Shape
    .arc()
    .cornerRadius(cornerRadius)
    .outerRadius(radius)
    .innerRadius(innerRadius);
  return pathFunction(defaults({ startAngle, endAngle, padAngle }, slice));
};
github FormidableLabs / victory / packages / victory-tooltip / src / victory-tooltip.js View on Github external
getEvaluatedProps(props) {
    const { horizontal, pointerLength, pointerWidth, cornerRadius, centerOffset, dx, dy } = props;

    const active = Helpers.evaluateProp(props.active, props);
    const text = Helpers.evaluateProp(props.text, assign({}, props, { active }));
    const { style, flyoutStyle } = this.getStyles(assign({}, props, { active, text }));
    const orientation =
      Helpers.evaluateProp(
        props.orientation,
        assign({}, props, { active, text, style, flyoutStyle })
      ) || this.getDefaultOrientation(props);

    const labelSize = TextSize.approximateTextSize(text, style);
    const { flyoutHeight, flyoutWidth } = this.getDimensions(
      assign({}, props, { style, flyoutStyle, active, text, orientation }),
      labelSize
    );

    const evaluatedProps = assign({}, props, {
      active,
github FormidableLabs / victory / packages / victory-pie / src / slice.js View on Github external
const getPath = (props) => {
  const { slice, radius, innerRadius } = props;
  if (isFunction(props.pathFunction)) {
    return props.pathFunction(slice);
  }
  const cornerRadius = Helpers.evaluateProp(props.cornerRadius, props);
  const padAngle = Helpers.degreesToRadians(Helpers.evaluateProp(props.padAngle, props));
  const startAngle = Helpers.degreesToRadians(Helpers.evaluateProp(props.sliceStartAngle, props));
  const endAngle = Helpers.degreesToRadians(Helpers.evaluateProp(props.sliceEndAngle, props));
  const pathFunction = d3Shape
    .arc()
    .cornerRadius(cornerRadius)
    .outerRadius(radius)
    .innerRadius(innerRadius);
  return pathFunction(defaults({ startAngle, endAngle, padAngle }, slice));
};
github MayGo / tockler / client / src / components / Timeline / SimpleBar.tsx View on Github external
getCornerRadius(props) {
        const { cornerRadius, datum, active } = props;
        const realCornerRadius = { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 };
        if (!cornerRadius) {
            return realCornerRadius;
        }
        if (isPlainObject(cornerRadius)) {
            return this.getCornerRadiusFromObject(props);
        } else {
            realCornerRadius.topLeft = Helpers.evaluateProp(cornerRadius, datum, active);
            realCornerRadius.topRight = Helpers.evaluateProp(cornerRadius, datum, active);
            return realCornerRadius;
        }
    }
github FormidableLabs / victory / packages / victory-tooltip / src / victory-tooltip.js View on Github external
getFlyoutProps(props, calculatedValues) {
    const { flyoutDimensions, flyoutStyle, flyoutCenter } = calculatedValues;
    const {
      x,
      y,
      dx,
      dy,
      datum,
      index,
      pointerLength,
      pointerWidth,
      cornerRadius,
      events,
      flyoutComponent
    } = props;
    const pointerOrientation = Helpers.evaluateProp(props.pointerOrientation, props);
    return defaults({}, flyoutComponent.props, {
      x,
      y,
      dx,
      dy,
      datum,
      index,
      pointerLength,
      pointerWidth,
      cornerRadius,
      events,
      orientation:
        pointerOrientation || this.getPointerOrientation({ x, y }, flyoutCenter, flyoutDimensions),
      key: `${this.id}-tooltip-${index}`,
      width: flyoutDimensions.width,
      height: flyoutDimensions.height,
github FormidableLabs / victory / packages / victory-tooltip / src / victory-tooltip.js View on Github external
return Math.max(minHeight, calculatedHeight);
    };
    const getWidth = () => {
      const calculatedWidth = labelSize.width + padding;
      const minWidth =
        orientation === "left" || orientation === "right"
          ? 2 * cornerRadius + pointerLength
          : 2 * cornerRadius;
      return Math.max(minWidth, calculatedWidth);
    };
    return {
      flyoutHeight: flyoutHeight
        ? Helpers.evaluateProp(flyoutHeight, props)
        : getHeight(props, labelSize, orientation) + padding / 2,
      flyoutWidth: flyoutWidth
        ? Helpers.evaluateProp(flyoutWidth, props)
        : getWidth(props, labelSize, orientation) + padding
    };
  }