2019-09-24 14:51:13 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2020-02-14 10:10:54 +08:00
|
|
|
<meta charset="UTF-8" />
|
2019-09-24 14:51:13 +08:00
|
|
|
<title>Grid</title>
|
|
|
|
</head>
|
2020-02-14 10:10:54 +08:00
|
|
|
|
2019-09-24 14:51:13 +08:00
|
|
|
<body>
|
|
|
|
<div id="mountNode"></div>
|
|
|
|
<script src="../build/grid.js"></script>
|
|
|
|
<script src="../build/g6.js"></script>
|
|
|
|
<script>
|
|
|
|
const data = {
|
|
|
|
nodes: [
|
|
|
|
{
|
|
|
|
id: '0',
|
|
|
|
label: 'node-0',
|
|
|
|
x: 100,
|
2020-02-14 10:10:54 +08:00
|
|
|
y: 100,
|
2019-09-24 14:51:13 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: '1',
|
|
|
|
label: 'node-1',
|
|
|
|
x: 250,
|
2020-02-14 10:10:54 +08:00
|
|
|
y: 100,
|
2019-09-24 14:51:13 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: '2',
|
|
|
|
label: 'node-2',
|
|
|
|
x: 150,
|
2020-02-14 10:10:54 +08:00
|
|
|
y: 350,
|
2019-09-24 14:51:13 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: '3',
|
|
|
|
label: 'node-3',
|
|
|
|
x: 420,
|
2020-02-14 10:10:54 +08:00
|
|
|
y: 380,
|
2019-09-24 14:51:13 +08:00
|
|
|
},
|
2020-02-14 10:10:54 +08:00
|
|
|
],
|
|
|
|
};
|
2019-09-24 14:51:13 +08:00
|
|
|
const grid = new Grid();
|
|
|
|
const graph = new G6.Graph({
|
|
|
|
container: 'mountNode',
|
|
|
|
width: 800,
|
|
|
|
height: 600,
|
2020-02-14 10:10:54 +08:00
|
|
|
plugins: [grid],
|
2019-09-24 14:51:13 +08:00
|
|
|
defaultNode: {
|
|
|
|
size: [80, 40],
|
2020-02-14 10:10:54 +08:00
|
|
|
shape: 'rect',
|
2019-09-24 14:51:13 +08:00
|
|
|
},
|
|
|
|
modes: {
|
2020-02-14 10:10:54 +08:00
|
|
|
default: ['zoom-canvas', 'drag-canvas', 'drag-node'],
|
|
|
|
},
|
2019-09-24 14:51:13 +08:00
|
|
|
});
|
|
|
|
graph.data(data);
|
|
|
|
graph.render();
|
|
|
|
</script>
|
|
|
|
</body>
|
2020-02-14 10:10:54 +08:00
|
|
|
</html>
|