-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_edge_labels.html
More file actions
99 lines (90 loc) · 2.37 KB
/
test_edge_labels.html
File metadata and controls
99 lines (90 loc) · 2.37 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Cytoscape Edge Label Test</title>
<style>
#cy {
width: 100%;
height: 600px;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<h1>Cytoscape.js Edge Label Test</h1>
<div id="cy"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.30.2/cytoscape.min.js"></script>
<script>
var cy = cytoscape({
container: document.getElementById('cy'),
elements: [
// Nodes
{ data: { id: 'a', label: 'Node A' } },
{ data: { id: 'b', label: 'Node B' } },
{ data: { id: 'c', label: 'Node C' } },
// Edges with different label approaches
{
data: {
id: 'ab',
source: 'a',
target: 'b',
label: 'edge label AB', // Direct label
relation_display: 'inhibits' // Custom data
}
},
{
data: {
id: 'bc',
source: 'b',
target: 'c',
label: 'activates',
relation_display: 'activates'
}
},
],
layout: {
name: 'grid',
rows: 1
},
style: [
{
selector: 'node',
style: {
'label': 'data(label)',
'background-color': '#666',
'color': '#fff',
'text-valign': 'center',
'text-halign': 'center',
'font-size': '14px'
}
},
{
selector: 'edge',
style: {
'label': 'data(label)', // Test with direct label first
'width': 3,
'line-color': '#ccc',
'curve-style': 'bezier',
// Text styling
'font-size': '14px',
'font-weight': 'bold',
'color': '#000',
// Background
'text-background-color': '#fff',
'text-background-opacity': 1,
'text-background-padding': '4px',
// Positioning
'text-rotation': 'autorotate',
'text-margin-y': -10
}
}
]
});
console.log('Cytoscape initialized');
console.log('Edges:', cy.edges().length);
cy.edges().forEach(function(edge) {
console.log('Edge:', edge.id(), 'label:', edge.data('label'));
});
</script>
</body>
</html>