From e792c857713f644f1fbf3d76090ce4f42765e465 Mon Sep 17 00:00:00 2001 From: skeris Date: Sat, 2 Dec 2023 14:52:33 +0300 Subject: [PATCH] fix tree layout --- .../Questions/BranchingMap/CsComponent.tsx | 133 +----------------- 1 file changed, 6 insertions(+), 127 deletions(-) diff --git a/src/pages/Questions/BranchingMap/CsComponent.tsx b/src/pages/Questions/BranchingMap/CsComponent.tsx index 7eca0a75..4491f6b2 100644 --- a/src/pages/Questions/BranchingMap/CsComponent.tsx +++ b/src/pages/Questions/BranchingMap/CsComponent.tsx @@ -231,7 +231,7 @@ const clearDataAfterRemoveNode = ({targetQuestionId, parentQuestionId}:{targetQu name: 'preset', positions: (e) => { - + console.log('POSITIIIIIIIONS') const id = e.id() const incomming = e.cy().edges(`[target="${id}"]`) const layer = 0 @@ -258,7 +258,7 @@ const clearDataAfterRemoveNode = ({targetQuestionId, parentQuestionId}:{targetQu while (queue.length) { const task = queue.pop() if (task.children.length === 0) { - task.parent.data('subtreeWidth', task.parent.height()) + task.parent.data('subtreeWidth', 0) continue } const unprocessed = task?.children.filter(e => { @@ -305,132 +305,11 @@ const clearDataAfterRemoveNode = ({targetQuestionId, parentQuestionId}:{targetQu useEffect(() => { document.querySelector("#root")?.addEventListener("mouseup", cleardragQuestionContentId); const cy = cyRef.current; + const eles = cy?.add(storeToNodes(questions)) +console.log('PETTY', storeToNodes(questions), eles.length) + const elecs = eles.layout(lyopts).run() - cy?.add(storeToNodes(questions)) - - // cy?.add(storeToNodes(questions)) - //cy?.on('add',()=>cy.fit()) - // const elecs = cy?.add( - // [ - // { - // "data": { - // "id": "1", - // "label": "нет имени" - // } - // }, - // { - // "data": { - // "id": "1 2", - // "label": "нет имени" - // } - // }, - // { - // "data": { - // "id": "1 3", - // "label": "нет имени" - // } - // }, - // { - // "data": { - // "id": "1 2 4", - // "label": "нет имени" - // } - // }, - // { - // "data": { - // "id": "1 2 6", - // "label": "нет имени" - // } - // }, - // { - // "data": { - // "id": "1 3 5", - // "label": "нет имени" - // } - // }, - // { - // "data": { - // "id": "1 3 7", - // "label": "нет имени" - // } - // }, - // { - // "data": { - // "id": "1 2 6 9867874", - // "label": "нет имени" - // } - // }, - // { - // "data": { - // "id": "1 2 6 7398789", - // "label": "нет имени" - // } - // }, - // { - // "data": { - // "id": "1 2 6 9484789", - // "label": "нет имени" - // } - // }, - // { - // "data": { - // "source": "1", - // "target": "1 2" - // } - // }, - // { - // "data": { - // "source": "1", - // "target": "1 3" - // } - // }, - // { - // "data": { - // "source": "1 2", - // "target": "1 2 4" - // } - // }, - // { - // "data": { - // "source": "1 2", - // "target": "1 2 6" - // } - // }, - // { - // "data": { - // "source": "1 3", - // "target": "1 3 5" - // } - // }, - // { - // "data": { - // "source": "1 3", - // "target": "1 3 7" - // } - // }, - // { - // "data": { - // "source": "1 2 6", - // "target": "1 2 6 9867874" - // } - // }, - // { - // "data": { - // "source": "1 2 6", - // "target": "1 2 6 7398789" - // } - // }, - // { - // "data": { - // "source": "1 2 6", - // "target": "1 2 6 9484789" - // } - // } - // ] - // ).layout(lyopts) - // elecs.run() - - //cy?.fit() + cy?.fit() //cy?.layout().run() return () => {