-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.html
100 lines (86 loc) · 2.97 KB
/
index.test.html
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!Doctype html>
<html>
<head>
<meta charset="utf-8">
<title>An awesome requirejs app</title>
<link rel="stylesheet" href="preview_assets/css/main.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.min.js"></script>
<script src="vendor/raphael/raphael.js"></script>
<script src="dist/graph.min.js"></script>
</head>
<body>
<h1>GraphEditor running!</h1>
<button type="button" class="get-json">Get JSON</button>
<button type="button" class="align-nodes">Align nodes</button>
<div class="graph-placeholder"></div>
<textarea name="json" id="json-area" cols="80" rows="20" disabled></textarea>
<script type="text/javascript">
$(document).ready(function () {
var canvas = new Graph({
$parent : $('.graph-placeholder'),
assetsUrl : '/',
editMode : true,
//TreeModel: tree,
constraints: {
connection: {
strokeWidth: 3,
disableWire: true,
pathType: Graph.PathTypes.BROKEN_CURVED_LINE
},
node : {
radius : 60,
borderWidth: 7,
labelOffset: 12,
selected: {
fill: '#ffffff'
},
//defaults
fill : '#011E37',
stroke: 'none'
},
connection: {
strokeWidth: 7,
disableWire: true,
pathType: Graph.PathTypes.BROKEN_CURVED_LINE
},
//terminal : {
// radius : 9,
// radiusInner: 6
//},
buttons : {
radius: 15,
border: 4
},
icons : {
default: 'preview_assets/images/icon-db.png'
}
}
});
console.log('Graph path types', Graph.PathTypes);
function getModel() {
return model = {
id : _.random(100000, 999999) + '',
name : 'Test node' + Date.now(),
inputs : [
{
id : _.random(100000, 999999) + '',
name: 'input'
}
],
outputs : [
{
id : _.random(100000, 999999) + '',
name: 'output'
}
],
properties: {}
};
}
var node = canvas.addNode(getModel(), {x: 150, y: 200}, false);
var node1 = canvas.addNode(getModel(), {x: 550, y: 100}, false);
canvas.connectNodes(node, node1, 'i am cool label');
});
</script>
</body>
</html>