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/pkg/_antv.g6-2.2.6/build/plugins.js"></script> <script src="https://gw.alipayobjects.com/os/antv/assets/lib/jquery-3.2.1.min.js"></script> <script src="https://gw.alipayobjects.com/os/antv/assets/lib/d3-4.13.0.min.js"></script> <script> $("#mountNode").css('backgroundColor', '#e5ddd1'); $.getJSON('https://gw.alipayobjects.com/os/antvdemo/assets/data/xiaomi.json', function(data) { var Mapper = G6.Plugins['tool.d3.mapper']; var _d = d3, forceSimulation = _d.forceSimulation, forceLink = _d.forceLink, forceManyBody = _d.forceManyBody, forceX = _d.forceX, forceY = _d.forceY, forceCollide = _d.forceCollide; var nodeMap = {}; var nodeSizeMapper = new Mapper('node', 'degree', 'size', [8, 48], { legendCfg: null }); var nodeColorMapper = new Mapper('node', 'type', 'color', ['#e18826', '#002a67']); var G = G6.G; var simulation = void 0; var graph = new G6.Graph({ container: 'mountNode', height: window.innerHeight, plugins: [nodeSizeMapper, nodeColorMapper], modes: { default: ['rightPanCanvas'] }, layout: function layout(nodes, edges) { if (simulation) { simulation.alphaTarget(0.3).restart(); } else { simulation = forceSimulation(nodes).force('charge', forceManyBody().strength(-100)).force('link', forceLink(edges).id(function(model) { return model.id; })).force('collision', forceCollide().radius(function(model) { return model.size / 2 * 1.2; })).force('y', forceY()).force('x', forceX()).on('tick', function() { graph.updateNodePosition(); }); } } }); graph.node({ style: function style(model) { if (model.type === 'Company') { return { fill: '#e18826', shadowColor: 'rgba(0,0,0, 0.3)', shadowBlur: 3, shadowOffsetX: 2, shadowOffsetY: 2, stroke: null }; } return { fill: '#002a67', shadowColor: 'rgba(0,0,0, 0.3)', shadowBlur: 3, shadowOffsetX: 3, shadowOffsetY: 5, stroke: null }; }, label: function label(model) { return { text: model.properties['name'], stroke: null, fill: '#fff' }; } }); graph.edge({ style: function style() { return { stroke: '#b3b3b3', lineWidth: 2 }; } }); graph.read(data); graph.translate(graph.getWidth() / 2, graph.getHeight() / 2); // 拖拽节点交互 var subject = void 0; // 逼近点 graph.on('mousedown', function(ev) { if (ev.domEvent.button === 0) { subject = simulation.find(ev.x, ev.y); } }); graph.on('dragstart', function(ev) { subject && simulation.alphaTarget(0.3).restart(); }); graph.on('drag', function(ev) { if (subject) { subject.fx = ev.x; subject.fy = ev.y; } }); graph.on('mouseup', resetState); graph.on('canvas:mouseleave', resetState); function resetState() { if (subject) { simulation.alphaTarget(0); subject.fx = null; subject.fy = null; subject = null; } } // 鼠标移入节点显示 label function tryHideLabel(node) { var model = node.getModel(); var label = node.getLabel(); var labelBox = label.getBBox(); if (labelBox.maxX - labelBox.minX > model.size) { label.hide(); graph.draw(); } } var nodes = graph.getNodes(); var edges = graph.getEdges(); edges.forEach(function(edge) { edge.getGraphicGroup().set('capture', false); // 移除边的捕获,提升图形拾取效率 }); nodes.forEach(function(node) { tryHideLabel(node); }); graph.on('node:mouseenter', function(ev) { var item = ev.item; graph.toFront(item); item.getLabel().show(); graph.draw(); }); graph.on('node:mouseleave', function(ev) { var item = ev.item; tryHideLabel(item); }); }); </script> </body> </html>
图表简介
展示了小米科技有限责任公司的企业关系图谱