feat: fix zoomToFit method usage GraphVisualization
This commit is contained in:
parent
583923903c
commit
79fb0595d8
1 changed files with 16 additions and 2 deletions
|
|
@ -217,11 +217,25 @@ export default function GraphVisualization({ ref, data, graphControls, className
|
||||||
|
|
||||||
const [graphShape, setGraphShape] = useState<string>();
|
const [graphShape, setGraphShape] = useState<string>();
|
||||||
|
|
||||||
|
const zoomToFit: ForceGraphMethods["zoomToFit"] = (
|
||||||
|
durationMs?: number,
|
||||||
|
padding?: number,
|
||||||
|
nodeFilter?: (node: NodeObject) => boolean
|
||||||
|
) => {
|
||||||
|
if (!graphRef.current) {
|
||||||
|
console.warn("GraphVisualization: graphRef not ready yet");
|
||||||
|
return undefined as any;
|
||||||
|
}
|
||||||
|
|
||||||
|
return graphRef.current.zoomToFit?.(durationMs, padding, nodeFilter);
|
||||||
|
};
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
zoomToFit: graphRef.current!.zoomToFit,
|
zoomToFit,
|
||||||
setGraphShape: setGraphShape,
|
setGraphShape,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={containerRef} className={classNames("w-full h-full", className)} id="graph-container">
|
<div ref={containerRef} className={classNames("w-full h-full", className)} id="graph-container">
|
||||||
<ForceGraph
|
<ForceGraph
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue