-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexjsdemo
48 lines (45 loc) · 1.14 KB
/
indexjsdemo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
document.addEventListener('DOMContentLoaded', function() {
var cy = cytoscape({
container: document.getElementById('cy'),
layout: {
name: 'grid',
rows: 1
},
style: [
{
selector: 'node',
style: {
'background-color': '#666',
'label': 'data(id)'
}
},
{
selector: 'edge',
style: {
'width': 3,
'line-color': '#ccc',
'target-arrow-color': '#ccc',
'target-arrow-shape': 'triangle'
}
}
],
elements: {
nodes: [
{ data: { id: 'a' } },
{ data: { id: 'b' } }
],
edges: []
},
});
cy.edgehandles({
preview: true,
hoverDelay: 150,
handleNodes: 'node',
handlePosition: 'middle top',
complete: function(sourceNode, targetNode, addedEles) {
console.log('Edge added between ' + sourceNode.id() + ' and ' + targetNode.id());
console.log(addedEles);
}
});
cy.edgehandles.enableDrawMode(); // Enable draw mode after initializing edgehandles
});