forked from anvaka/ngraph.pixel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
54 lines (43 loc) · 1.63 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
/**
* 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;
/**
* 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;
return options;
}
function defaultNode(/* node */) {
return { size: 20, color: 0xFF0894 };
}
function defaultLink(/* link */) {
return { fromColor: 0xFFFFFF, toColor: 0xFFFFFF };
}