mirror of
https://gitee.com/antv/g6.git
synced 2024-12-15 10:01:09 +08:00
79 lines
1.7 KiB
HTML
79 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
<title>工作流-网图</title>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="mountNode"></div>
|
|
<script src="../build/g6.js"></script>
|
|
<script src="../build/g6Plugins.js"></script>
|
|
<script>
|
|
G6.registerNode('rect', {
|
|
getPath(item) {
|
|
const width = 100; // 一半宽
|
|
const height = 40; // 一半高
|
|
return G6.Util.getRectPath(-width/2, -height/2, width, height, 10);
|
|
}
|
|
});
|
|
const data = {
|
|
nodes: [{
|
|
id: '收集日志',
|
|
}, {
|
|
id: '入 es 集群',
|
|
}, {
|
|
id: '入 hdfs',
|
|
}, {
|
|
id: 'hive 计算',
|
|
},{
|
|
id: 'report',
|
|
}],
|
|
edges: [{
|
|
source: '收集日志',
|
|
target: '入 es 集群'
|
|
},{
|
|
source: '收集日志',
|
|
target: '入 hdfs'
|
|
},{
|
|
source: '入 hdfs',
|
|
target: 'hive 计算'
|
|
},{
|
|
source: '入 es 集群',
|
|
target: 'hive 计算'
|
|
},{
|
|
source: 'hive 计算',
|
|
target: 'report'
|
|
}]
|
|
};
|
|
const graph = new G6.Graph({
|
|
container: 'mountNode',
|
|
plugins: [new G6.Plugins['layout.dagre']()],
|
|
width: 500,
|
|
height: 500,
|
|
defaultIntersectBox: 'rect' // 使用
|
|
});
|
|
graph.node({
|
|
shape: 'rect',
|
|
label(model) {
|
|
return model.id;
|
|
},
|
|
style: {
|
|
stroke: '#00C0A5',
|
|
fill: '#92949F',
|
|
fillOpacity: 0.45,
|
|
lineWidth: 2
|
|
}
|
|
});
|
|
graph.edge({
|
|
style: {
|
|
endArrow: true
|
|
}
|
|
});
|
|
graph.read(data);
|
|
</script>
|
|
</body>
|
|
</html> |