g6/demos/gallery-borning.html

72 lines
1.4 KiB
HTML
Raw Normal View History

2018-08-03 22:04:10 +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">
<title>画廊-无聊</title>
</head>
<body>
<div id="mountNode"></div>
<div id="mountNode"></div>
<script src="../build/g6.js"></script>
<script>
G6.registerNode('custom', {
draw(item) {
const group = item.getGraphicGroup();
let keyShape;
for (let i = 0; i < 20; i++) {
keyShape = group.addGroup().addShape('circle', {
attrs: {
x: 0,
y: i * 12,
r: i * 4,
fill: 'rgba(29,109,29, 0.1)'
}
});
}
return keyShape;
}
});
const data = {
nodes: [{
id: 'node0',
x: -100,
y: 200
}, {
id: 'node1',
x: 100,
y: 200
}, {
id: 'node2',
x: 300,
y: 200
}, {
id: 'node3',
x: 600,
y: 200
}],
edges: [{
target: 'node0',
source: 'node1'
}, {
target: 'node2',
source: 'node1'
}, {
target: 'node2',
source: 'node3'
}]
};
const graph = new G6.Graph({
container: 'mountNode',
fitView: 'cc',
height: window.innerHeight,
});
graph.node({
shape: 'custom'
});
graph.read(data);
</script>
</body>
</html>