How to use victory-core - 10 common examples

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 / src / components / victory-chart / victory-chart.jsx View on Github external
getCalculatedProps(props, childComponents) {
    const horizontal = childComponents.some((component) => component.props.horizontal);
    const axisComponents = {
      x: Axis.getAxisComponent(childComponents, "x"),
      y: Axis.getAxisComponent(childComponents, "y")
    };
    const domain = {
      x: ChartHelpers.getDomain(props, childComponents, "x"),
      y: ChartHelpers.getDomain(props, childComponents, "y")
    };
    const range = {
      x: Helpers.getRange(props, "x"),
      y: Helpers.getRange(props, "y")
    };
    const baseScale = {
      x: Scale.getScaleFromProps(props, "x") ||
        axisComponents.x && axisComponents.x.type.getScale(axisComponents.x.props) ||
        Scale.getDefaultScale(),
      y: Scale.getScaleFromProps(props, "y") ||
        axisComponents.y && axisComponents.y.type.getScale(axisComponents.y.props) ||
        Scale.getDefaultScale()
    };
    const scale = {
      x: baseScale.x.domain(domain.x).range(range.x),
      y: baseScale.y.domain(domain.y).range(range.y)
    };
    // TODO: check
    const categories = {
github FormidableLabs / victory / packages / victory-candlestick / src / helper-methods.js View on Github external
const getBaseProps = (props, fallbackProps) => {
  // eslint-disable-line max-statements
  props = Helpers.modifyProps(props, fallbackProps, "candlestick");
  const calculatedValues = getCalculatedValues(props);
  const { data, style, scale, domain, origin, labelOrientation } = calculatedValues;
  const {
    groupComponent,
    width,
    height,
    padding,
    standalone,
    name,
    candleWidth,
    candleRatio,
    theme,
    polar,
    wickStrokeWidth,
    labels,
    events,
github FormidableLabs / victory-chart / src / components / victory-chart / victory-chart.js View on Github external
};

    // TODO: check
    const categories = {
      x: Wrapper.getCategories(props, "x", childComponents),
      y: Wrapper.getCategories(props, "y", childComponents)
    };

    const stringMap = {
      x: createStringMap(props, "x", childComponents),
      y: createStringMap(props, "y", childComponents)
    };

    const defaultDomainPadding = getDefaultDomainPadding(childComponents, horizontal);

    const padding = Helpers.getPadding(props);

    return {
      axisComponents, categories, domain, range, horizontal, scale, stringMap,
      style, origin, originSign, defaultDomainPadding, padding
    };
  }
github FormidableLabs / victory / packages / victory-scatter / src / helper-methods.js View on Github external
const getMaxRadius = () => {
    const minPadding = Math.min(...values(Helpers.getPadding(props)));
    return Math.max(minPadding, 5); // eslint-disable-line no-magic-numbers
  };
  const maxRadius = maxBubbleSize || getMaxRadius();
github FormidableLabs / victory / packages / victory-pie / src / victory-pie.js View on Github external
static defaultProps = {
    data: [
      { x: "A", y: 1 },
      { x: "B", y: 2 },
      { x: "C", y: 3 },
      { x: "D", y: 1 },
      { x: "E", y: 2 }
    ],
    standalone: true,
    dataComponent: ,
    labelComponent: ,
    containerComponent: ,
    groupComponent:
github FormidableLabs / victory / src / components / victory-bar / bar-label.jsx View on Github external
renderLabelComponent(props, position, anchors) {
    const component = props.labelComponent;
    const baseStyle = defaults({}, component.props.style, props.style, {padding: 0});
    const style = Helpers.evaluateStyle(baseStyle, props.datum);
    const padding = this.getlabelPadding(props, style);
    const labelText = props.labelText || props.datum.label;
    const index = [props.index.seriesIndex, props.index.barIndex];
    const baseEvents = component && component.props.events ?
      defaults({}, component.props.events, props.events) : props.events;
    const events = Helpers.getPartialEvents(baseEvents, index, props);
    const newProps = {
      index: [props.index.seriesIndex, props.index.barIndex],
      x: component.props.x || position.x + padding.x,
      y: component.props.y || position.y - padding.y,
      datum: props.datum, // Pass datum for custom label component to access
      text: labelText,
      textAnchor: component.props.textAnchor || anchors.text,
      verticalAnchor: component.props.verticalAnchor || anchors.vertical,
      style,
      events
    };
    return React.cloneElement(component, newProps);
  }
github FormidableLabs / victory / src / components / slice-label.js View on Github external
renderLabelComponent(props, position, label) {
    const component = props.labels;
    const style = Helpers.evaluateStyle(
      defaults({}, component.props.style, props.style, {padding: 0}),
      this.data
    );
    const baseEvents = component && component.props.events ?
      defaults({}, component.props.events, props.events) : props.events;
    const events = Helpers.getPartialEvents(baseEvents, props.index, props);
    const newProps = assign({}, events, {
      x: component.props.x || position[0],
      y: component.props.y || position[1],
      datum: props.datum, // Pass data for custom label component to access
      textAnchor: component.props.textAnchor || "start",
      verticalAnchor: component.props.verticalAnchor || "middle",
      text: component.props.text || label,
      style
    });
    return React.cloneElement(component, newProps);
  }
github FormidableLabs / victory-chart / src / components / victory-chart / victory-chart.js View on Github external
y: props.polar ? Helpers.getPolarRange(props, "y") : Helpers.getRange(props, "y")
    };
    const baseScale = {
      x: Scale.getScaleFromProps(props, "x") ||
        axisComponents.x && axisComponents.x.type.getScale(axisComponents.x.props) ||
        Scale.getDefaultScale(),
      y: Scale.getScaleFromProps(props, "y") ||
        axisComponents.y && axisComponents.y.type.getScale(axisComponents.y.props) ||
        Scale.getDefaultScale()
    };
    const scale = {
      x: baseScale.x.domain(domain.x).range(range.x),
      y: baseScale.y.domain(domain.y).range(range.y)
    };

    const origin = props.polar ? Helpers.getPolarOrigin(props) : Axis.getOrigin(domain);

    const originSign = {
      x: Axis.getOriginSign(origin.x, domain.x),
      y: Axis.getOriginSign(origin.y, domain.y)
    };

    // TODO: check
    const categories = {
      x: Wrapper.getCategories(props, "x", childComponents),
      y: Wrapper.getCategories(props, "y", childComponents)
    };

    const stringMap = {
      x: createStringMap(props, "x", childComponents),
      y: createStringMap(props, "y", childComponents)
    };
github FormidableLabs / victory-chart / src / components / victory-chart / victory-chart.js View on Github external
x: Axis.getAxisComponent(childComponents, "x"),
      y: Axis.getAxisComponent(childComponents, "y")
    };
    const domain = {
      x: getDomain(props, "x", childComponents),
      y: getDomain(props, "y", childComponents)
    };
    const range = {
      x: props.polar ? Helpers.getPolarRange(props, "x") : Helpers.getRange(props, "x"),
      y: props.polar ? Helpers.getPolarRange(props, "y") : Helpers.getRange(props, "y")
    };
    const baseScale = {
      x: Scale.getScaleFromProps(props, "x") ||
        axisComponents.x && axisComponents.x.type.getScale(axisComponents.x.props) ||
        Scale.getDefaultScale(),
      y: Scale.getScaleFromProps(props, "y") ||
        axisComponents.y && axisComponents.y.type.getScale(axisComponents.y.props) ||
        Scale.getDefaultScale()
    };
    const scale = {
      x: baseScale.x.domain(domain.x).range(range.x),
      y: baseScale.y.domain(domain.y).range(range.y)
    };

    const origin = props.polar ? Helpers.getPolarOrigin(props) : Axis.getOrigin(domain);

    const originSign = {
      x: Axis.getOriginSign(origin.x, domain.x),
      y: Axis.getOriginSign(origin.y, domain.y)
    };

    // TODO: check