g6/demos/plugin-grid.html

60 lines
1.2 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
2020-02-14 10:10:54 +08:00
<meta charset="UTF-8" />
<title>Grid</title>
</head>
2020-02-14 10:10:54 +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,
},
{
id: '1',
label: 'node-1',
x: 250,
2020-02-14 10:10:54 +08:00
y: 100,
},
{
id: '2',
label: 'node-2',
x: 150,
2020-02-14 10:10:54 +08:00
y: 350,
},
{
id: '3',
label: 'node-3',
x: 420,
2020-02-14 10:10:54 +08:00
y: 380,
},
2020-02-14 10:10:54 +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],
defaultNode: {
size: [80, 40],
2020-02-14 10:10:54 +08:00
shape: 'rect',
},
modes: {
2020-02-14 10:10:54 +08:00
default: ['zoom-canvas', 'drag-canvas', 'drag-node'],
},
});
graph.data(data);
graph.render();
</script>
</body>
2020-02-14 10:10:54 +08:00
</html>