From 16c75a40a87b293ead2fa0f0b18ef924f9b0b851 Mon Sep 17 00:00:00 2001 From: Denis Shatskiy Date: Fri, 8 Aug 2025 16:03:30 +0700 Subject: [PATCH] feat: Enhance GraphView with improved zoom functionality and label styling, including shadows for better visibility and aesthetics --- frontend/src/GraphView.jsx | 90 +++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 31 deletions(-) diff --git a/frontend/src/GraphView.jsx b/frontend/src/GraphView.jsx index 1243e67..48175af 100644 --- a/frontend/src/GraphView.jsx +++ b/frontend/src/GraphView.jsx @@ -79,8 +79,11 @@ function GraphView({ servers, connections }) { // Контролы масштабирования const zoomBy = (factor) => { + if (!zoomRef.current || !svgRef.current) return; const svg = d3.select(svgRef.current); - svg.transition().duration(200).call(zoomRef.current.scaleBy, factor); + const node = svgRef.current; + const center = [node.clientWidth / 2, node.clientHeight / 2]; + svg.transition().duration(220).call(zoomRef.current.scaleBy, factor, center); }; const fitToView = () => { @@ -263,6 +266,10 @@ function GraphView({ servers, connections }) { + {/* Тень для ярлыков ссылок */} + + + {/* Подложка сетки */} @@ -309,36 +316,57 @@ function GraphView({ servers, connections }) { style={{ vectorEffect: 'non-scaling-stroke' }} /> - {/* Подпись связи */} - - - {connection.tunnelType} - - - {connection.ipA} ⇄ {connection.ipB} - + {/* Подпись связи: ярлык с подложкой и halo */} + {(() => { + const labelW = 140; + const labelH = 38; + const lx = cx - labelW / 2; + const ly = cy - labelH / 2 - 4; // слегка выше вершины + return ( + + + {/* Halo для заголовка */} + + {connection.tunnelType} + + {/* Линия IP с более мелким шрифтом */} + + {connection.ipA} ⇄ {connection.ipB} + + + ); + })()} ); })}