| author | ymh <ymh.work@gmail.com> |
| Fri, 15 Sep 2017 14:11:36 +0200 | |
| changeset 658 | cac26275af31 |
| parent 293 | fba23fde14ba |
| permissions | -rw-r--r-- |
| 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"]; |
|
| 170 | 7 |
var _proj = _renkan.project; |
|
293
fba23fde14ba
Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents:
170
diff
changeset
|
8 |
var i; |
|
fba23fde14ba
Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents:
170
diff
changeset
|
9 |
for (i = 0; i < _opts.user_count; i++) { |
| 23 | 10 |
_proj.addUser({ |
| 4 | 11 |
id: "user-"+i, |
12 |
title: "User #"+(1+i), |
|
| 23 | 13 |
color: _opts.user_colors[i] |
14 |
}); |
|
| 4 | 15 |
} |
|
293
fba23fde14ba
Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents:
170
diff
changeset
|
16 |
for (i = 0; i < _opts.node_count; i++) { |
| 23 | 17 |
_proj.addNode({ |
| 4 | 18 |
id: "node-"+i, |
19 |
title: "Node #"+(1+i), |
|
| 23 | 20 |
created_by: "user-" + Math.floor(_opts.user_count*Math.random()), |
| 4 | 21 |
position: { |
| 23 | 22 |
x: 300 * Math.cos(2 * Math.PI * i / _opts.node_count), |
23 |
y: 300 * Math.sin(2 * Math.PI * i / _opts.node_count) |
|
| 4 | 24 |
} |
| 23 | 25 |
}); |
| 4 | 26 |
} |
|
293
fba23fde14ba
Correct jshint errors and force it on build
ymh <ymh.work@gmail.com>
parents:
170
diff
changeset
|
27 |
for (i = 0; i < _opts.node_count; i++) { |
| 4 | 28 |
var _from, _to; |
| 23 | 29 |
_from = _to = Math.floor(_opts.node_count*Math.random()); |
| 4 | 30 |
while(_from === _to) { |
| 23 | 31 |
_to = Math.floor(_opts.node_count*Math.random()); |
| 4 | 32 |
} |
| 23 | 33 |
_proj.addEdge({ |
| 4 | 34 |
id: "edge-"+i, |
35 |
title: "Edge #"+(1+i), |
|
| 23 | 36 |
created_by: "user-" + Math.floor(_opts.user_count*Math.random()), |
| 4 | 37 |
from: "node-" + _from, |
38 |
to: "node-" + _to |
|
| 23 | 39 |
}); |
| 4 | 40 |
} |
| 23 | 41 |
_renkan.current_user = "user-0"; |
| 170 | 42 |
}; |