g6/demos/custom-flowing-edge.html
2018-08-03 22:04:10 +08:00

50 lines
952 B
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>
G6.registerEdge('flowingEdge', {
afterDraw(item) {
const keyShape = item.getKeyShape();
keyShape.attr('lineDash', [10, 10]);
keyShape.attr('lineDashOffset', 0);
keyShape.animate({
lineDashOffset: -20,
repeat: true
}, 500);
}
});
const data = {
nodes: [{
id: 'node1',
x: 100,
y: 200
},{
id: 'node2',
x: 300,
y: 200
}],
edges: [{
target: 'node2',
source: 'node1',
shape: 'flowingEdge'
}]
};
const graph = new G6.Graph({
container: 'mountNode',
fitView: 'cc',
height: window.innerHeight
});
graph.read(data);
</script>
</body>
</html>