How to use the victory-core.Helpers.evaluateStyle 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-candlestick / src / candle.js View on Github external
const evaluateProps = (props) => {
  // Potential evaluated props are 1) `style`, 2) `candleWidth`
  const style = Helpers.evaluateStyle(assign({ stroke: "black" }, props.style), props);
  const candleWidth = getCandleWidth(props.candleWidth, assign({}, props, { style }));
  return assign({}, props, { style, candleWidth });
};
github FormidableLabs / victory / packages / victory-tooltip / src / victory-tooltip.js View on Github external
      ? baseLabelStyle.map((s) => Helpers.evaluateStyle(s, props))
      : Helpers.evaluateStyle(baseLabelStyle, props);
github FormidableLabs / victory / packages / victory-pie / src / helper-methods.js View on Github external
const getLabelProps = (text, dataProps, calculatedValues) => {
  const { index, datum, data, slice } = dataProps;
  const { style, defaultRadius, origin, width, height } = calculatedValues;
  const labelRadius = Helpers.evaluateProp(
    calculatedValues.labelRadius,
    assign({ text }, dataProps)
  );
  const labelPosition = Helpers.evaluateProp(
    calculatedValues.labelPosition,
    assign({ text }, dataProps)
  );
  const labelStyle = assign({ padding: 0 }, style.labels);
  const evaluatedStyle = Helpers.evaluateStyle(
    labelStyle,
    assign({ labelRadius, text }, dataProps)
  );
  const labelArc = getLabelArc(defaultRadius, labelRadius, evaluatedStyle);
  const position = getLabelPosition(labelArc, slice, labelPosition);
  const orientation = getLabelOrientation(slice);
  return {
    width,
    height,
    index,
    datum,
    data,
    slice,
    orientation,
    text,
    style: labelStyle,
github FormidableLabs / victory / src / components / victory-line / line-label.jsx View on Github external
renderVictoryLabel(props) {
    const style = Helpers.evaluateStyle(defaults({}, props.style), props.data, {padding: 0});
    const events = Helpers.getPartialEvents(this.props.events, 0, this.props);
    return (
      
    );
  }
github FormidableLabs / victory / src / components / victory-line / line-label.jsx View on Github external
renderLabelComponent(props) {
    const component = props.label;
    const baseStyle = defaults({}, component.props.style, props.style, {padding: 0});
    const style = Helpers.evaluateStyle(baseStyle, props.data);
    const baseEvents = component && component.props.events ?
      defaults({}, component.props.events, props.events) : props.events;
    const events = Helpers.getPartialEvents(baseEvents, 0, props);
    const newProps = {
      x: component.props.x || props.position.x + style.padding,
      y: component.props.y || props.position.y - style.padding,
      data: props.data,
      text: component.props.text,
      textAnchor: component.props.textAnchor || "start",
      verticalAnchor: component.props.verticalAnchor || "middle",
      style,
      events
    };
    return React.cloneElement(component, newProps);
  }
github FormidableLabs / victory / packages / victory-voronoi / src / voronoi.js View on Github external
active,
      role,
      shapeRendering,
      className,
      events,
      x,
      y,
      transform,
      pathComponent,
      clipPathComponent,
      groupComponent,
      circleComponent,
      id
    } = this.props;
    const voronoiPath = this.getVoronoiPath(this.props);
    const style = Helpers.evaluateStyle(this.props.style, datum, active);
    const size = Helpers.evaluateProp(this.props.size, datum, active);

    if (size) {
      const circle = React.cloneElement(circleComponent, {
        key: `${id}-circle-clip`,
        style,
        className,
        role,
        shapeRendering,
        events,
        clipPath: `url(#${this.clipId})`,
        cx: x,
        cy: y,
        r: size
      });
      const voronoiClipPath = React.cloneElement(
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),
      React.cloneElement(handleComponent, maxHandleProps)
    ];
  }
github FormidableLabs / victory / src / components / victory-scatter / point-label.jsx View on Github external
renderLabel(props) {
    if (props.showLabels === false || !props.datum.label) {
      return undefined;
    }
    const component = props.labelComponent;
    const componentStyle = component && component.props.style || {};
    const baseStyle = defaults({}, componentStyle, props.style);
    const labelStyle = Helpers.evaluateStyle(baseStyle, props.datum);
    const labelText = component && component.props.text || props.datum.label;
    const baseEvents = component && component.props.events ?
      defaults({}, component.props.events, props.events) : props.events;
    const events = Helpers.getPartialEvents(baseEvents, props.index, props);
    const labelProps = {
      x: component && component.props.x || props.position.x,
      y: component && component.props.y || props.position.y - labelStyle.padding,
      dy: component && component.props.dy,
      datum: props.datum,
      text: labelText,
      textAnchor: component && component.props.textAnchor || labelStyle.textAnchor,
      verticalAnchor: component && component.props.verticalAnchor || "end",
      style: labelStyle,
      events
    };
github FormidableLabs / victory / packages / victory-tooltip / src / victory-tooltip.js View on Github external
getStyles(props) {
    const theme = props.theme || VictoryTheme.grayscale;
    const defaultLabelStyles =
      theme && theme.tooltip && theme.tooltip.style ? theme.tooltip.style : {};
    const baseLabelStyle = Array.isArray(props.style)
      ? props.style.map((s) => defaults({}, s, defaultLabelStyles))
      : defaults({}, props.style, defaultLabelStyles);
    const defaultFlyoutStyles =
      theme && theme.tooltip && theme.tooltip.flyoutStyle ? theme.tooltip.flyoutStyle : {};
    const baseFlyoutStyle = props.flyoutStyle
      ? defaults({}, props.flyoutStyle, defaultFlyoutStyles)
      : defaultFlyoutStyles;
    const style = Array.isArray(baseLabelStyle)
      ? baseLabelStyle.map((s) => Helpers.evaluateStyle(s, props))
      : Helpers.evaluateStyle(baseLabelStyle, props);
    const flyoutStyle = Helpers.evaluateStyle(baseFlyoutStyle, assign({}, props, { style }));
    return { style, flyoutStyle };
  }