diff --git a/web/epiphany-graph-viewer/src/lib/EpiphanyGraphViewer.tsx b/web/epiphany-graph-viewer/src/lib/EpiphanyGraphViewer.tsx index 4b93a2c..3ac8117 100644 --- a/web/epiphany-graph-viewer/src/lib/EpiphanyGraphViewer.tsx +++ b/web/epiphany-graph-viewer/src/lib/EpiphanyGraphViewer.tsx @@ -182,6 +182,7 @@ export function EpiphanyGraphViewer({ const activeLayout = layouts?.[activeGraphKey] ?? null; const activeTransform = transforms[activeGraphKey]; + const compactGraph = activeLayout ? isCompactGraphLayout(activeLayout) : false; const selectedNode = selection?.kind === "node" && selection.graphKey === activeGraphKey && activeLayout ? activeLayout.nodes.find((node) => node.id === selection.nodeId) ?? null @@ -443,7 +444,7 @@ export function EpiphanyGraphViewer({ strokeLinejoin="round" vectorEffect="non-scaling-stroke" /> - {(isSelected || isConnected || activeTransform.scale > 1.75) && + {(isSelected || isConnected || (!compactGraph && activeTransform.scale > 1.75)) && edge.label?.trim() && ( - - - - {node.badgeText} - + + + + + + + + {node.badgeText} + - {node.status?.trim() && node.width >= 112 && activeTransform.scale > 0.66 && ( - + {node.status?.trim() && node.width >= 128 && node.height >= 52 && activeTransform.scale > 0.66 && ( + {node.status.toUpperCase()} - - )} + + )} - {node.linkCount > 0 && node.width >= 52 && node.height >= 42 && ( - + {node.linkCount > 0 && node.width >= 72 && node.height >= 54 && ( + {node.linkCount} + + )} + + = 112 && node.height >= 44 ? fadeBetween(activeTransform.scale, 0.5, 0.82) : 0} pointerEvents="none"> + {renderTextLines( + copyLayout.titleLines, + 44, + 26, + 15, + { + fill: "#f8fbff", + fontSize: 13, + fontWeight: 800, + }, + )} - )} - = 86 ? fadeBetween(activeTransform.scale, 0.5, 0.82) : 0} pointerEvents="none"> - {renderTextLines( - copyLayout.titleLines, - 44, - 26, - 15, - { - fill: "#f8fbff", - fontSize: 13, - fontWeight: 800, - }, - )} - + = 180 && node.height >= 92 ? fadeBetween(activeTransform.scale, 1.02, 1.44) : 0} pointerEvents="none"> + {renderTextLines( + copyLayout.purposeLines, + 16, + copyLayout.purposeStartY, + 12.5, + { + fill: "rgba(229, 238, 248, 0.88)", + fontSize: 10.6, + }, + )} + - - {renderTextLines( - copyLayout.purposeLines, - 16, - copyLayout.purposeStartY, - 12.5, - { - fill: "rgba(229, 238, 248, 0.88)", - fontSize: 10.6, - }, - )} - - - - {renderTextLines( - copyLayout.mechanismLines, - 16, - copyLayout.mechanismStartY, - 11.5, - { - fill: "rgba(103, 232, 249, 0.86)", - fontSize: 9.4, - }, - )} - {renderTextLines( - copyLayout.metaphorLines, - 16, - copyLayout.metaphorStartY, - 11.2, - { - fill: "rgba(244, 114, 182, 0.84)", - fontSize: 9.1, - }, - )} + = 230 && node.height >= 125 ? fadeBetween(activeTransform.scale, 1.55, 1.92) : 0} pointerEvents="none"> + {renderTextLines( + copyLayout.mechanismLines, + 16, + copyLayout.mechanismStartY, + 11.5, + { + fill: "rgba(103, 232, 249, 0.86)", + fontSize: 9.4, + }, + )} + {renderTextLines( + copyLayout.metaphorLines, + 16, + copyLayout.metaphorStartY, + 11.2, + { + fill: "rgba(244, 114, 182, 0.84)", + fontSize: 9.1, + }, + )} + ); @@ -1417,6 +1427,20 @@ function nodeOpacity( return 0.36; } +function isCompactGraphLayout(layout: GraphLayout) { + if (layout.nodes.length === 0) { + return false; + } + + const widths = layout.nodes.map((node) => node.width).sort((left, right) => left - right); + const medianWidth = widths[Math.floor(widths.length / 2)] ?? 0; + return medianWidth < 96; +} + +function safeDomId(value: string) { + return value.replace(/[^a-zA-Z0-9_-]/g, "-"); +} + function fadeBetween(value: number, start: number, end: number) { if (value <= start) { return 0;