| | |
| | | _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') { |
| | |
| | | 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 |
| | |
| | | parent.children = null |
| | | } else { |
| | | parent.children = parent.children.map(item => { |
| | | item = this.getTree(item, options) |
| | | item = this.getTree(item, options, root) |
| | | |
| | | return item |
| | | }) |
| | |
| | | graph.render() |
| | | graph.fitView() |
| | | |
| | | if (plot.collapsed === 'true') { |
| | | if (plot.collapsed === 'true' || data.nodeNumber < 5) { |
| | | graph.zoomTo(1, { x: 0, y: plot.height / 2 }) |
| | | } |
| | | } |
| | |
| | | |
| | | 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 }) |
| | | } |
| | | } |