Skip to main content

Events

Description

We provide three of click event interfaces; onClickNode, onClickEdge, onClickBackground.

export interface ServerMapProps {
data: {
nodes: Node[],
edges: Edge[],
};
baseNodeId: string;
customTheme?: any;
onClickNode?: ClickEventHandler<MergedNode>;
onClickEdge?: ClickEventHandler<MergedEdge>;
onClickBackground?: ClickEventHandler<{}>;
renderNodeLabel?: (node: MergedNode) => string | undefined;
renderEdgeLabel?: (edge: MergedEdge) => string | undefined;
}

type ClickEventHandler<T> = (param: {
data?: T,
eventType: 'right' | 'left',
position: cytoscape.Position,
}) => void;

onClickNode

Callback to execute when clicking nodes.

Props of Callback Parameter

PropsTypedescription
dataMergedNode : { nodes?: Node[] } & NodeTarget node data
eventType"right" or "left"Mouse click type
positioncytoscape.Position : { x: number, y: number }Coordinates where the event occurred

onClickEdge

Callback to execute when clicking edges.

Props of Callback Parameter

PropsTypedescription
dataMergedEdge : { nodes?: Edge[] } & EdgeTarge edge data
eventType"right" or "left"Mouse click type
positioncytoscape.Position : { x: number, y: number }Coordinates where the event occurred

onClickBackground

Callback to execute when clicking background.

Props of Callback Parameter

PropsTypedescription
eventType"right" or "left"Mouse click type
positioncytoscape.Position : { x: number, y: number }Coordinates where the event occurred