From 7f0368c2c8e827c2240419d7bc7a9299c296a2ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Thu, 3 Apr 2025 17:16:32 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E5=B8=A6=E9=B1=BC=E5=A4=B4?= =?UTF-8?q?=E9=B1=BC=E5=B0=BE=E7=9A=84=E9=B1=BC=E9=AA=A8=E5=9B=BE=E4=BA=8C?= =?UTF-8?q?=E7=BA=A7=E8=8A=82=E7=82=B9=E5=AE=9A=E4=BD=8D=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/layouts/Fishbone.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/simple-mind-map/src/layouts/Fishbone.js b/simple-mind-map/src/layouts/Fishbone.js index cdb6f0c7..18a30e60 100644 --- a/simple-mind-map/src/layouts/Fishbone.js +++ b/simple-mind-map/src/layouts/Fishbone.js @@ -184,10 +184,14 @@ class Fishbone extends Base { // 计算二级节点的top值 if (parent._node.isRoot) { let marginY = this.getMarginY(layerIndex) + // 带鱼头鱼尾的鱼骨图因为根节点高度比较大,所以二级节点需要向中间靠一点 + const topOffset = this.isFishbone2() ? parent._node.height / 4 : 0 if (this.checkIsTop(newNode)) { - newNode.top = parent._node.top - newNode.height - marginY + newNode.top = + parent._node.top - newNode.height - marginY + topOffset } else { - newNode.top = parent._node.top + parent._node.height + marginY + newNode.top = + parent._node.top + parent._node.height + marginY - topOffset } } } @@ -209,8 +213,11 @@ class Fishbone extends Base { (node, parent, isRoot, layerIndex) => { if (node.isRoot) { let marginX = this.getMarginX(layerIndex + 1) - let topTotalLeft = node.left + node.width + node.height + marginX - let bottomTotalLeft = node.left + node.width + node.height + marginX + const heightOffsetRatio = this.isFishbone2() ? 2 : 1 + let topTotalLeft = + node.left + node.width + node.height / heightOffsetRatio + marginX + let bottomTotalLeft = + node.left + node.width + node.height / heightOffsetRatio + marginX node.children.forEach(item => { if (this.checkIsTop(item)) { item.left = topTotalLeft @@ -384,7 +391,8 @@ class Fishbone extends Base { // 水平线段到二级节点的连线 let marginY = this.getMarginY(item.layerIndex) let nodeLineX = item.left - let offset = node.height / 2 + marginY + let offset = + node.height / 2 + marginY - (this.isFishbone2() ? node.height / 4 : 0) let offsetX = offset / Math.tan(degToRad(this.mindMap.opt.fishboneDeg)) let line = this.lineDraw.path() if (this.checkIsTop(item)) {