forked from cytoscape/cytoscape.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperformance-tuning.js
57 lines (47 loc) · 1.4 KB
/
performance-tuning.js
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
yourDiv.style.left = 0;
yourDiv.style.top = 0;
yourDiv.style.width = "100%";
yourDiv.style.height = "100%";
yourDiv.style.position = "absolute";
var fetchJson = function( path ){
return fetch( path ).then(function( res ){
return res.json();
});
};
var cytoscape = require("cytoscape");
var cy = cytoscape({
// these options hide parts of the graph during interaction
//hideEdgesOnViewport: true,
//hideLabelsOnViewport: true,
// this is an alternative that uses a bitmap during interaction
// textureOnViewport: true,
// interpolate on high density displays instead of increasing resolution
pixelRatio: 1,
// a motion blur effect that increases perceived performance for little or no cost
// motionBlur: true,
container: yourDiv,
style: cytoscape.stylesheet()
.selector('node')
.style({
'width': 'mapData(weight, 0, 100, 10, 60)',
'height': 'mapData(weight, 0, 100, 10, 60)'
})
.selector('edge')
.style({
'opacity': '0.666',
'width': 'mapData(weight, 0, 100, 1, 6)',
'curve-style': 'haystack' // fast edges!
})
.selector(':selected')
.style({
'background-color': 'black',
'opacity': 1
}),
layout: {
name: 'concentric',
concentric: function( node ){ return node.data('weight'); },
levelWidth: function( nodes ){ return 10; },
padding: 10
},
elements: fetchJson('./data/performance-tuning.json')
});