@@ -56,8 +56,8 @@ export const Sidebar: React.FC<SidebarProps> = ({
|
|||||||
}, [agents, searchQuery]);
|
}, [agents, searchQuery]);
|
||||||
|
|
||||||
const graphData: GraphData = useMemo(() => {
|
const graphData: GraphData = useMemo(() => {
|
||||||
const nodes = [];
|
const nodes: any[] = [];
|
||||||
const links = [];
|
const links: any[] = [];
|
||||||
|
|
||||||
agents.forEach((agent) => {
|
agents.forEach((agent) => {
|
||||||
nodes.push({
|
nodes.push({
|
||||||
|
|||||||
@@ -138,15 +138,11 @@ export const ForceGraph = forwardRef<any, ForceGraphProps>(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fit zoom on engine stop
|
const handleEngineStop = () => {
|
||||||
useEffect(() => {
|
if (typeof ref !== "function" && ref && "current" in ref && ref.current) {
|
||||||
if (ref && typeof ref === "object" && ref.current) {
|
ref.current.zoomToFit(400);
|
||||||
const timer = setTimeout(() => {
|
|
||||||
ref.current?.zoomToFit(400);
|
|
||||||
}, 100);
|
|
||||||
return () => clearTimeout(timer);
|
|
||||||
}
|
}
|
||||||
}, [data, ref]);
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={containerRef} className="w-full h-full relative">
|
<div ref={containerRef} className="w-full h-full relative">
|
||||||
@@ -180,6 +176,7 @@ export const ForceGraph = forwardRef<any, ForceGraphProps>(
|
|||||||
d3AlphaDecay={0.03}
|
d3AlphaDecay={0.03}
|
||||||
d3VelocityDecay={0.4}
|
d3VelocityDecay={0.4}
|
||||||
warmupTicks={50}
|
warmupTicks={50}
|
||||||
|
onEngineStop={handleEngineStop}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user