g6/demos/gallery-workflow.html

80 lines
1.7 KiB
HTML
Raw Normal View History

2018-06-14 20:02:45 +08:00
<!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">
2018-07-18 10:12:45 +08:00
<title>画廊-工作流</title>
2018-06-14 20:02:45 +08:00
</head>
<body>
<div id="mountNode"></div>
<script src="../build/g6.js"></script>
2018-07-16 15:35:43 +08:00
<script src="../build/plugin.layout.dagre.js"></script>
2018-06-14 20:02:45 +08:00
<script>
G6.registerNode('rect', {
getPath(item) {
const width = 100; // 一半宽
const height = 40; // 一半高
return G6.Util.getRectPath(-width/2, -height/2, width, height, 10);
},
2018-06-14 20:02:45 +08:00
});
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',
2018-06-14 20:02:45 +08:00
width: 500,
height: 500,
plugins: [new G6.Plugins['layout.dagre']()],
defaultIntersectBox: 'rect' // 使用矩形包围盒
2018-06-14 20:02:45 +08:00
});
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>