Skip to content

Commit

Permalink
vis: tree display: sort lists to reduce unnecessary node movement
Browse files Browse the repository at this point in the history
  • Loading branch information
dyc3 committed Apr 3, 2024
1 parent d9a6df7 commit 87e14be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/ott-vis-panel/src/components/TreeDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ const TreeDisplay: React.FC<TreeDisplayProps> = ({
}) => {
const svgRef = useRef<SVGSVGElement | null>(null);
// const systemTree = useMemo(() => buildFullTree(systemState), [systemState]);
const monolithTrees = buildMonolithTrees(systemState.flatMap(b => b.monoliths));
const monolithTrees = buildMonolithTrees(systemState.flatMap(b => b.monoliths)).sort((a, b) => d3.ascending(a.region, b.region) || d3.ascending(a.id, b.id));

const [chartTransform, setChartTransform] = useState("translate(0, 0)");

Expand Down Expand Up @@ -300,6 +300,7 @@ const TreeDisplay: React.FC<TreeDisplayProps> = ({
const builtMonolithTrees: d3.HierarchyNode<TreeNode>[] = [];
for (const monolithTree of monolithTrees) {
const root = constructMonolithSubtreesBasic(monolithTree, baseNodeRadius);
root.sort((a, b) => d3.ascending(a.data.id, b.data.id));
builtMonolithTrees.push(root);
}

Expand Down Expand Up @@ -353,7 +354,7 @@ const TreeDisplay: React.FC<TreeDisplayProps> = ({
y: i * yincr,
};
return node;
});
}).sort((a, b) => d3.ascending(a.region, b.region) || d3.ascending(a.id, b.id));

const tr = d3.transition().duration(1000).ease(d3.easeCubicInOut);

Expand Down

0 comments on commit 87e14be

Please sign in to comment.