How to use the recharts/lib/util/ReactUtils.findChildByType function in recharts

To help you get started, we’ve selected a few recharts 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 Vizzuality / gfw / app / javascript / components / charts / sankey-chart / sankey-component.js View on Github external
handleMouseEnter(el, type, e) {
    const { onMouseEnter, children } = this.props;
    const tooltipItem = findChildByType(children, Tooltip);

    if (tooltipItem) {
      this.setState(
        {
          activeElement: el,
          activeElementType: type,
          isTooltipActive: true
        },
        () => {
          if (onMouseEnter) {
            onMouseEnter(el, type, e);
          }
        }
      );
    } else if (onMouseEnter) {
      onMouseEnter(el, type, e);
github Vizzuality / gfw / app / javascript / components / charts / sankey-chart / sankey-component.js View on Github external
handleMouseLeave(el, type, e) {
    const { onMouseLeave, children } = this.props;
    const tooltipItem = findChildByType(children, Tooltip);

    if (tooltipItem) {
      this.setState(
        {
          isTooltipActive: false
        },
        () => {
          if (onMouseLeave) {
            onMouseLeave(el, type, e);
          }
        }
      );
    } else if (onMouseLeave) {
      onMouseLeave(el, type, e);
    }
  }
github Vizzuality / gfw / app / javascript / components / charts / sankey-chart / sankey-component.js View on Github external
renderTooltip() {
    const { children, width, height, nameKey } = this.props;
    const tooltipItem = findChildByType(children, Tooltip);

    if (!tooltipItem) {
      return null;
    }

    const { isTooltipActive, activeElement, activeElementType } = this.state;
    const viewBox = { x: 0, y: 0, width, height };
    const coordinate = activeElement
      ? getCoordinateOfTooltip(activeElement, activeElementType)
      : defaultCoordinateOfTooltip;
    const payload = activeElement
      ? getPayloadOfTooltip(activeElement, activeElementType, nameKey)
      : [];

    return React.cloneElement(tooltipItem, {
      viewBox,