|
23
|
1 |
Rkns.randomData = function(_renkan, _opts) { |
|
|
2 |
_opts = _opts || {}; |
|
|
3 |
_opts.user_count = _opts.user_count || 5; |
|
|
4 |
_opts.node_count = _opts.node_count || 20; |
|
|
5 |
_opts.edge_count = _opts.edge_count || 2 * _opts.node_count; |
|
|
6 |
_opts.user_colors = _opts.user_colors || ["#ff0000", "#008000", "#0000ff", "#808000", "#808080", "#c000c0", "#00c0c0"]; |
|
|
7 |
var _proj = _renkan.project |
|
|
8 |
for (var i = 0; i < _opts.user_count; i++) { |
|
|
9 |
_proj.addUser({ |
|
4
|
10 |
id: "user-"+i, |
|
|
11 |
title: "User #"+(1+i), |
|
23
|
12 |
color: _opts.user_colors[i] |
|
|
13 |
}); |
|
4
|
14 |
} |
|
23
|
15 |
for (var i = 0; i < _opts.node_count; i++) { |
|
|
16 |
_proj.addNode({ |
|
4
|
17 |
id: "node-"+i, |
|
|
18 |
title: "Node #"+(1+i), |
|
23
|
19 |
created_by: "user-" + Math.floor(_opts.user_count*Math.random()), |
|
4
|
20 |
position: { |
|
23
|
21 |
x: 300 * Math.cos(2 * Math.PI * i / _opts.node_count), |
|
|
22 |
y: 300 * Math.sin(2 * Math.PI * i / _opts.node_count) |
|
4
|
23 |
} |
|
23
|
24 |
}); |
|
4
|
25 |
} |
|
23
|
26 |
for (var i = 0; i < _opts.node_count; i++) { |
|
4
|
27 |
var _from, _to; |
|
23
|
28 |
_from = _to = Math.floor(_opts.node_count*Math.random()); |
|
4
|
29 |
while(_from === _to) { |
|
23
|
30 |
_to = Math.floor(_opts.node_count*Math.random()); |
|
4
|
31 |
} |
|
23
|
32 |
_proj.addEdge({ |
|
4
|
33 |
id: "edge-"+i, |
|
|
34 |
title: "Edge #"+(1+i), |
|
23
|
35 |
created_by: "user-" + Math.floor(_opts.user_count*Math.random()), |
|
4
|
36 |
from: "node-" + _from, |
|
|
37 |
to: "node-" + _to |
|
23
|
38 |
}); |
|
4
|
39 |
} |
|
23
|
40 |
_renkan.current_user = "user-0"; |
|
4
|
41 |
} |