g6/demos/gallery-workflow.html
2018-08-10 17:18:46 +08:00

82 lines
1.8 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/plugin.layout.dagre.js"></script>
<script src="../build/plugin.edge.polyline.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',
fitView: 'cc',
width: 500,
height: 500,
plugins: [new G6.Plugins['layout.dagre']()],
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
},
shape: 'polyline-round'
});
graph.read(data);
</script>
</body>
</html>