Skip to content

Commit 250cc3b

Browse files
committed
vis: tree display: apply minor optimizations
1 parent cac5396 commit 250cc3b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/ott-vis-panel/src/components/TreeDisplay.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,9 @@ const TreeDisplay: React.FC<TreeDisplayProps> = ({ systemState, width, height })
467467
});
468468
const balancerMonolithLinks = gb2mLinks
469469
.selectAll(".b2m-link")
470-
.data(b2mLinkData, (d: any) => d.source?.data?.id + d.target?.data?.id);
470+
// TODO: add key function to data join when balancer ids are stable
471+
// .data(b2mLinkData, (d: any) => d.source?.data?.id + d.target?.data?.id);
472+
.data(b2mLinkData);
471473
balancerMonolithLinks
472474
.join(
473475
create =>
@@ -487,19 +489,22 @@ const TreeDisplay: React.FC<TreeDisplayProps> = ({ systemState, width, height })
487489

488490
const zoom = d3.zoom<SVGSVGElement, TreeNode>().on("zoom", handleZoom);
489491
function handleZoom(e: any) {
492+
svg.select("g.chart").attr("transform", e.transform);
490493
setChartTransform(e.transform);
491494
}
492495
svg.call(zoom);
493496
}
494-
}, [systemState, monolithTrees, width, height]);
497+
}, [systemState, monolithTrees]);
495498

499+
// run this only once after the first render
496500
useEffect(() => {
497501
if (!svgRef.current) {
498502
return;
499503
}
500504
const svg = d3.select<SVGSVGElement, TreeNode>(svgRef.current);
501505
svg.select("g.chart").attr("transform", chartTransform);
502-
}, [chartTransform]);
506+
// eslint-disable-next-line react-hooks/exhaustive-deps
507+
}, []);
503508

504509
const eventBus = useEventBus();
505510
useEffect(() => {

0 commit comments

Comments
 (0)