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