G6
G2
G6
F2
L7
墨者学院
关于 G6
图表示例
API 文档
使用教程
返回旧版
树图
紧凑树
系统树
生态树
脑图树
函数生成树
Newick
流图
ATM 投资关系图
表格桑基图
工作流
网图
小米关系图谱
浙江省各城市大学分布
粒子传输效果
系统增长
2017 Link Data
编辑器
简单流程图
模型流程图
脑图
网络图建模
脑图树
源码
复制成功
复制失败
全屏
复制
运行
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>脑图树</title> <style>::-webkit-scrollbar{display:none;}html,body{overflow:hidden;margin:0;}</style> </head> <body> <div id="mountNode"></div> <script>/*Fixing iframe window.innerHeight 0 issue in Safari*/document.body.clientHeight;</script> <script src="https://gw.alipayobjects.com/os/antv/pkg/_antv.g6-3.1.1/build/g6.js"></script> <script src="https://gw.alipayobjects.com/os/antv/pkg/_antv.g6-2.2.0/build/g6.js"></script> <script src="https://gw.alipayobjects.com/os/antv/assets/lib/jquery-3.2.1.min.js"></script> <script> $.getJSON('https://gw.alipayobjects.com/os/antvdemo/assets/data/modeling-methods.json', function(data) { G6.registerNode('treeNode', { anchor: [[0, 0.5], [1, 0.5]] }); G6.registerEdge('smooth', { getPath: function getPath(item) { var points = item.getPoints(); var start = points[0]; var end = points[points.length - 1]; var hgap = Math.abs(end.x - start.x); if (end.x > start.x) { return [['M', start.x, start.y], ['C', start.x + hgap / 4, start.y, end.x - hgap / 2, end.y, end.x, end.y]]; } return [['M', start.x, start.y], ['C', start.x - hgap / 4, start.y, end.x + hgap / 2, end.y, end.x, end.y]]; } }); var layout = new G6.Layouts.Mindmap({ direction: 'H', // 方向(LR/RL/H/TB/BT/V) getHGap: function getHGap() /* d */ { // 横向间距 return 100; }, getVGap: function getVGap() /* d */ { // 竖向间距 return 10; } }); var tree = new G6.Tree({ id: 'mountNode', // 容器ID height: window.innerHeight, // 画布高 layout: layout, fitView: 'autoZoom' // 自动缩放 }); tree.node({ shape: 'treeNode', size: 8, label: function label(model) { return model.name; } }); tree.edge({ shape: 'smooth' }); tree.on('afterchange', function() { tree.getNodes().forEach(function(node) { var model = node.getModel(); var label = node.getLabel(); var keyShape = node.getKeyShape(); var parent = node.getParent(); var box = keyShape.getBBox(); var labelBox = label.getBBox(); var dx = (box.maxX - box.minX + labelBox.maxX - labelBox.minX) / 2 + 8; var dy = (box.maxY - box.minY) / 2 + 8; if (parent) { var parentModel = parent.getModel(); if (parentModel.x > model.x) { dx = -dx; } dy = 0; } else { dx = 0; } label.attr({ x: dx, y: dy }); }); tree.draw(); }); tree.read({ roots: [data] }); }); </script> </body> </html>