openreplay/frontend/app/components/shared/Insights/SankeyChart/CustomLink.tsx
Shekar Siri 89704b033f
feat(ui) - path analysis (#1514)
* fix(ui) - insight item name

* feat(ui) - path analysis - wip

* feat(ui) - path analysis - wip

* feat(ui) - path analysis

* feat(ui) - user retention

* feat(ui): path analysis - filters and graph

* change(ui): plugins text and icon

* feat(ui): path analysis - filters and graph

* feat(ui): path analysis - filters and graph

* feat(ui): path analysis

* feat(ui): path analysis - start point filters

* feat(ui): path analysis
2023-10-12 17:04:19 +02:00

45 lines
1.4 KiB
TypeScript

import React from 'react';
import { Layer } from 'recharts';
function CustomLink(props: any) {
const [fill, setFill] = React.useState('url(#linkGradient)');
const { payload, sourceX, targetX, sourceY, targetY, sourceControlX, targetControlX, linkWidth, index, activeLink } =
props;
const activeSource = activeLink?.payload.source;
const activeTarget = activeLink?.payload.target;
const isActive = activeSource?.name === payload.source.name && activeTarget?.name === payload.target.name;
const onClick = () => {
if (props.onClick) {
props.onClick(props);
}
};
return (
<Layer key={`CustomLink${index}`} onClick={onClick}>
<path
d={`
M${sourceX},${sourceY + linkWidth / 2}
C${sourceControlX},${sourceY + linkWidth / 2}
${targetControlX},${targetY + linkWidth / 2}
${targetX},${targetY + linkWidth / 2}
L${targetX},${targetY - linkWidth / 2}
C${targetControlX},${targetY - linkWidth / 2}
${sourceControlX},${sourceY - linkWidth / 2}
${sourceX},${sourceY - linkWidth / 2}
Z
`}
fill={isActive ? 'rgba(57, 78, 255, 0.5)' : fill}
strokeWidth='0'
onMouseEnter={() => {
setFill('rgba(57, 78, 255, 0.5)');
}}
onMouseLeave={() => {
setFill('url(#linkGradient)');
}}
/>
</Layer>
);
}
export default CustomLink;