fix: graphs
ci-front / build (push) Successful in 2m5s

This commit is contained in:
nikita
2026-04-04 12:38:21 +03:00
parent aac3fa3758
commit e7f1ea2386
6 changed files with 544 additions and 466 deletions
+9 -29
View File
@@ -11,6 +11,7 @@ import {
GraphControls,
GraphContextMenu,
GraphStatusBar,
GraphStats,
} from "./components";
interface GraphProps {
@@ -25,7 +26,6 @@ export const Graph: React.FC<GraphProps> = ({
onDataChange,
}) => {
const fgRef = useRef<any>(null);
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
const [contextMenu, setContextMenu] = useState<ContextMenuState | null>(null);
const data = useGraphStore((s) => s.data);
@@ -38,25 +38,6 @@ export const Graph: React.FC<GraphProps> = ({
if (initialData) setData(initialData);
}, [initialData, setData]);
// Отслеживаем размеры контейнера
useEffect(() => {
const container = fgRef.current?.parentElement;
if (!container) return;
const updateDimensions = () => {
setDimensions({
width: container.clientWidth,
height: container.clientHeight || window.innerHeight - 160,
});
};
updateDimensions();
const observer = new ResizeObserver(updateDimensions);
observer.observe(container);
return () => observer.disconnect();
}, []);
// Закрыть контекстное меню по клику вне
useEffect(() => {
const handleClickOutside = () => setContextMenu(null);
@@ -89,16 +70,14 @@ export const Graph: React.FC<GraphProps> = ({
}
return (
<div className="bg-gray-900 rounded-xl shadow-lg p-6">
<div
className="border border-gray-800 rounded-lg overflow-hidden relative"
style={{
height: "calc(100vh - 200px)",
position: "relative",
width: "100%",
}}
>
<div className="bg-gray-900 p-4 h-full flex flex-col">
{/* Статистика сверху */}
<GraphStats data={data} />
{/* Граф */}
<div className="flex-1 border border-gray-800 rounded-lg overflow-hidden relative mt-2">
<ForceGraph
ref={fgRef}
data={data}
onNodeRightClick={handleNodeRightClick}
onLinkRightClick={handleLinkRightClick}
@@ -113,6 +92,7 @@ export const Graph: React.FC<GraphProps> = ({
<GraphStatusBar isLinkMode={isLinkMode} selectedNode={selectedNode} />
</div>
{/* Кнопки снизу */}
<GraphControls
fgRef={fgRef}
onExport={onExport}