diff --git a/src/components/Universe/Graph/Cubes/NodePoints/index.tsx b/src/components/Universe/Graph/Cubes/NodePoints/index.tsx index 2a2fac254..ddb0e35a0 100644 --- a/src/components/Universe/Graph/Cubes/NodePoints/index.tsx +++ b/src/components/Universe/Graph/Cubes/NodePoints/index.tsx @@ -59,7 +59,7 @@ const _NodePoints = () => { const primaryColor = normalizedSchemasByType[node.node_type]?.primary_color const color = primaryColor ?? (COLORS_MAP[nodeTypes.indexOf(node.node_type)] || colors.white) - return + return })} diff --git a/src/components/Universe/Graph/Cubes/index.tsx b/src/components/Universe/Graph/Cubes/index.tsx index 844ccff98..73dfb9295 100644 --- a/src/components/Universe/Graph/Cubes/index.tsx +++ b/src/components/Universe/Graph/Cubes/index.tsx @@ -114,7 +114,7 @@ export const Cubes = memo(() => { const hide = !!selectedNode && (relativeIds.includes(node.ref_id) || selectedNode.ref_id === node.ref_id) return ( - + ()( count: currentNodes.filter((node) => filter === 'all' || node.node_type?.toLowerCase() === filter).length, })) + const minScale = 1 + const maxScale = 4 + + // Find min and max edgeCount values + const minEdgeCount = Math.min(...currentNodes.map((node) => node.edge_count)) + const maxEdgeCount = Math.max(...currentNodes.map((node) => node.edge_count)) + + // Normalize and calculate scale for each node + const normalizedNodes = currentNodes.map((node) => { + const { edge_count: edgeCount } = node + const count = edgeCount || 1 + + const scale = Math.round( + ((count - minEdgeCount) / (maxEdgeCount - minEdgeCount)) * (maxScale - minScale) + minScale, + ) + + // Return new object with calculated scale + return { ...node, scale } + }) + set({ - dataInitial: { nodes: currentNodes, links: currentLinks }, + dataInitial: { nodes: normalizedNodes, links: currentLinks }, dataNew: { nodes: newNodes, links: newLinks }, isFetching: false, isLoadingNew: false,