forked from anvaka/ngraph.pixel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
76 lines (61 loc) · 2.48 KB
/
options.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* This file contains all possible configuration optins for the renderer
*/
module.exports = validateOptions;
var createLayout = require('pixel.layout'); // the default layout
function validateOptions(options) {
options = options || {};
/**
* Where to render the graph? Assume `document.body` by default.
*/
options.container = options.container || document.body;
/**
/* Let the renderer automatically fit the graph to available screen space.
* Enabled by default.
* Note: The autofit will only be executed until first user input.
*/
options.autoFit = options.autoFit !== undefined ? options.autoFit : true;
/**
* Background of the scene in hexadecimal form. Default value is 0x000000 (black);
*/
options.clearColor = typeof options.clearColor === 'number' ? options.clearColor : 0x000000;
/**
* Clear color opacity from 0 (transparent) to 1 (opaque); Default value is 1;
*/
options.clearAlpha = typeof options.clearAlpha === 'number' ? options.clearAlpha : 1;
/**
* Layout algorithm factory. Valid layout algorithms are required to have just two methods:
* `getNodePosition(nodeId)` and `step()`. See `pixel.layout` module for the
* reference: https://github.com/anvaka/pixel.layout
*/
options.createLayout = typeof options.createLayout === 'function' ? options.createLayout : createLayout;
/**
* Experimental API: How link should be rendered?
*/
options.link = typeof options.link === 'function' ? options.link : defaultLink;
/**
* Experimental API: How node should be rendered?
*/
options.node = typeof options.node === 'function' ? options.node : defaultNode;
/**
* Experimental API: When activeNode is explicitly set to false, then no proxy
* object is created. Which means actual updates to the node have to be manual
*
* TODO: Extend this documentation if this approach sticks.
*/
options.activeNode = typeof options.activeNode === 'undefined' ? true : options.activeNode;
/**
* Experimental API: When activeLink is explicitly set to false, then no proxy
* object is created for links. Which means actual updates to the link have to be manual
*
* TODO: Extend this documentation if this approach sticks.
*/
options.activeLink = typeof options.activeLink === 'undefined' ? true : options.activeLink;
return options;
}
function defaultNode(/* node */) {
return { size: 20, color: 0xFF0894 };
}
function defaultLink(/* link */) {
return { fromColor: 0xFFFFFF, toColor: 0xFFFFFF };
}