UNPKG

@visactor/react-vchart

Version:

The react version of VChart 4.x

28 lines (24 loc) 1.18 kB
import React from "react"; import { isObject, pickWithout } from "@visactor/vutils"; import { VChart } from "@visactor/vchart"; export const createTooltip = (componentName, specName, registers) => { registers && registers.length && VChart.useRegisters(registers); const ignoreKeys = [ "updateId", "componentId", "children" ], Comp = props => { const updateId = React.useRef(props.updateId); return props.updateId !== updateId.current && (updateId.current = props.updateId), null; }; return Comp.displayName = componentName, Comp.parseSpec = props => { const newTooltipSpec = pickWithout(props, ignoreKeys); return !props.tooltipRender && props.children && (newTooltipSpec.tooltipRender = (tooltipElement, actualTooltip, params) => React.Children.map(props.children, (child => isObject(child) ? React.cloneElement(child, { tooltipElement: tooltipElement, actualTooltip: actualTooltip, params: params }) : child))), { spec: newTooltipSpec, specName: specName, isSingle: !0 }; }, Comp; }; //# sourceMappingURL=BaseTooltip.js.map