From 21bf04e18831c3328d60e1eddf8c29b36a56b211 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Fri, 5 Apr 2024 16:45:42 -0400 Subject: [PATCH] vis: TopologyView: adjust node packing logic (#1624) --- .../src/components/views/TopologyView.tsx | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/ott-vis-panel/src/components/views/TopologyView.tsx b/packages/ott-vis-panel/src/components/views/TopologyView.tsx index 3181ee9c8..499728bd3 100644 --- a/packages/ott-vis-panel/src/components/views/TopologyView.tsx +++ b/packages/ott-vis-panel/src/components/views/TopologyView.tsx @@ -232,12 +232,11 @@ export const TopologyView: React.FC = ({ let balancerYs = 0; for (const tree of region.balancerTrees) { - const shouldPack = tree.leaves().length > 6; - const radius = calcGoodTreeRadius( - tree, - shouldPack ? clientNodeRadius / 2 : clientNodeRadius, - shouldPack ? 0 : 4 - ); + let radius = calcGoodTreeRadius(tree, clientNodeRadius, 4); + const shouldPack = radius > 200; + if (shouldPack) { + radius = calcGoodTreeRadius(tree, clientNodeRadius / 2, 0); + } const layout = d3.tree().size([-Math.PI, radius]); layout(tree); // precompute radial coordinates @@ -266,11 +265,11 @@ export const TopologyView: React.FC = ({ } let monolithYs = 0; for (const tree of region.monolithTrees) { - const shouldPack = tree.leaves().length > 6; - const radius = calcGoodTreeRadius( - tree, - shouldPack ? baseNodeRadius / 2 : baseNodeRadius - ); + let radius = calcGoodTreeRadius(tree, baseNodeRadius); + const shouldPack = radius > 200; + if (shouldPack) { + radius = calcGoodTreeRadius(tree, baseNodeRadius / 2); + } const layout = d3.tree().size([Math.PI, radius]); layout(tree); // precompute radial coordinates