From 03fb8af6eb071bef24a1ab3224905c13f238241d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 18 六月 2023 15:49:13 +0800 Subject: [PATCH] 2023-06-18 --- src/tabviews/custom/components/chart/antv-G6/index.jsx | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/tabviews/custom/components/chart/antv-G6/index.jsx b/src/tabviews/custom/components/chart/antv-G6/index.jsx index 8406f8d..31417fb 100644 --- a/src/tabviews/custom/components/chart/antv-G6/index.jsx +++ b/src/tabviews/custom/components/chart/antv-G6/index.jsx @@ -1184,7 +1184,8 @@ _options.push(_item) }) - root = this.getTree(root, _options) + root.nodeNumber = 0 + root = this.getTree(root, _options, root) root.children = root.children || [] if (plot.subtype === 'mindmap') { @@ -1248,13 +1249,16 @@ return root } - getTree = (parent, options) => { + getTree = (parent, options, root) => { parent.children = [] // 娣诲姞鑿滃崟鐨勫瓙鍏冪礌 options = options.filter(option => { if (option.$parentId === parent.id) { delete option.$parentId parent.children.push(option) + + root.nodeNumber++ + return false } return true @@ -1264,7 +1268,7 @@ parent.children = null } else { parent.children = parent.children.map(item => { - item = this.getTree(item, options) + item = this.getTree(item, options, root) return item }) @@ -1357,7 +1361,7 @@ graph.render() graph.fitView() - if (plot.collapsed === 'true') { + if (plot.collapsed === 'true' || data.nodeNumber < 5) { graph.zoomTo(1, { x: 0, y: plot.height / 2 }) } } @@ -1480,7 +1484,7 @@ if (plot.collapsed === 'true' && plot.dirField) { tree.zoomTo(1, { x: width / 2, y: plot.height / 2 }) - } else if (plot.collapsed === 'true') { + } else if (plot.collapsed === 'true' || data.nodeNumber < 5) { tree.zoomTo(1, { x: 0, y: plot.height / 2 }) } } -- Gitblit v1.8.0