How to use the victory-core.Helpers.getPartialEvents 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 / 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 / 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-axis / axis-label.jsx View on Github external
renderLabelComponent(props) {
    const component = props.label;
    const style = defaults({}, component.props.style, props.style);
    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,
      y: component.props.y || props.position.y,
      text: component.props.text,
      textAnchor: component.props.textAnchor || "middle",
      verticalAnchor: component.props.verticalAnchor || props.verticalAnchor,
      transform: component.props.transform || props.transform,
      style,
      events
    };
    return React.cloneElement(component, newProps);
  }
github FormidableLabs / victory / src / components / slice-label.js View on Github external
renderVictoryLabel(props, position, label) {
    const style = Helpers.evaluateStyle(
      assign({padding: 0}, props.style),
      props.datum
    );
    const events = Helpers.getPartialEvents(props.events, props.index, props);
    return (
      
    );
  }
github FormidableLabs / victory / src / components / victory-axis / tick-label.jsx View on Github external
render() {
    const { props } = this;
    if (!props.label) {
      return undefined;
    }
    const componentProps = props.label.props || {};
    const style = componentProps.style || props.style;
    const anchors = this.getAnchors(props);
    const baseEvents = componentProps.events ?
      defaults({}, componentProps.events, props.events) : props.events;
    const events = Helpers.getPartialEvents(baseEvents, props.index, props);
    const newProps = {
      x: props.position.x,
      y: props.position.y,
      textAnchor: componentProps.textAnchor || anchors.textAnchor,
      verticalAnchor: componentProps.verticalAnchor || anchors.verticalAnchor,
      style: Helpers.evaluateStyle(style, props.tick),
      events
    };
    return props.label.props ?
      React.cloneElement(props.label, newProps) :
      React.createElement(VictoryLabel, newProps, props.label);
  }
}
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
    };

    return component ?
      React.cloneElement(component, labelProps) :
      React.createElement(VictoryLabel, labelProps);
  }
github FormidableLabs / victory / src / components / victory-axis / axis-label.jsx View on Github external
renderVictoryLabel(props) {
    const events = Helpers.getPartialEvents(this.props.events, 0, this.props);
    const text = typeof props.label === "string" ? props.label : null;
    return (
      
    );
  }
github FormidableLabs / victory / src / components / victory-area / area-label.jsx View on Github external
renderLabelComponent(props) {
    const component = props.labelComponent;
    const baseStyle = defaults({padding: 0}, component.props.style, props.style);
    const style = Helpers.evaluateStyle(baseStyle, props.data);
    const children = component.props.children || props.labelText || "";
    const baseEvents = component && component.props.events ?
      defaults({}, component.props.events, props.events) : props.events;
    const events = Helpers.getPartialEvents(baseEvents, 0, props);
    const newProps = assign({}, events, {
      x: component.props.x || props.position.x + style.padding,
      y: component.props.y || props.position.y - style.padding,
      textAnchor: component.props.textAnchor || "start",
      verticalAnchor: component.props.verticalAnchor || "middle",
      style
    });
    return React.cloneElement(component, newProps, children);
  }