Skip to content

Commit 97f188c

Browse files
improvement of graph rendering
1 parent 07d0f6a commit 97f188c

File tree

1 file changed

+27
-36
lines changed

1 file changed

+27
-36
lines changed

resources/views/graph.blade.php

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
56
<title>Dependency Graph</title>
67
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.21.1/cytoscape.min.js"></script>
78
<style>
89
#cy {
9-
width: 800px;
10-
height: 600px;
10+
width: 100%;
11+
height: 80vh;
1112
border: 1px solid #ccc;
13+
margin: auto;
1214
}
1315
</style>
1416
</head>
@@ -31,53 +33,42 @@
3133
selector: 'node',
3234
style: {
3335
'background-color': function(ele) {
34-
var instability = ele.data('instability');
35-
if (instability > 0.80) {
36-
return 'red';
37-
} else if (instability > 0.60) {
38-
return 'orange';
39-
} else {
40-
return 'green';
41-
}
36+
let instability = ele.data('instability');
37+
return instability > 0.8 ? '#d9534f' :
38+
instability > 0.6 ? '#f0ad4e' :
39+
instability > 0.4 ? '#5bc0de' : '#5cb85c';
40+
},
41+
'label': function(ele) {
42+
const fullId = ele.data('id');
43+
return fullId.split('\\').pop();
4244
},
43-
'label': 'data(id)',
44-
'color': 'black',
45-
'text-valign': 'center'
45+
'color': '#333',
46+
'font-size': '10px',
47+
'text-outline-width': 2,
48+
'text-outline-color': '#ffffff',
49+
'text-valign': 'center',
50+
'text-wrap': 'wrap',
51+
'text-max-width': '80px'
4652
}
4753
},
4854
{
4955
selector: 'edge',
5056
style: {
51-
'width': 7,
52-
'line-color': '#ccc',
53-
'target-arrow-color': '#ccc',
57+
'width': 4,
58+
'line-color': '#cccccc',
59+
'target-arrow-color': '#cccccc',
5460
'target-arrow-shape': 'triangle',
55-
'curve-style': 'bezier'
61+
'curve-style': 'bezier',
62+
'opacity': 0.8
5663
}
5764
}
5865
],
5966
layout: {
60-
name: 'breadthfirst',
61-
directed: true
67+
name: 'cose',
68+
animate: true,
69+
animationDuration: 500
6270
}
6371
});
64-
65-
cy.nodes().forEach(function(ele) {
66-
ele.qtip({
67-
content: ele.data('id'),
68-
position: {
69-
my: 'top center',
70-
at: 'bottom center'
71-
},
72-
style: {
73-
classes: 'qtip-bootstrap',
74-
tip: {
75-
width: 16,
76-
height: 8
77-
}
78-
}
79-
});
80-
});
8172
</script>
8273
</body>
8374

0 commit comments

Comments
 (0)