-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatasets.js
37 lines (33 loc) · 849 Bytes
/
datasets.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
const min = 0,
max = 100,
minItems = 300,
maxItems = 500;
const getRandomNum = (min,max) => {
return Math.random()*(max-min)+min;
}
//set number of items for the array
const getNumberOfItems = (minItems, maxItems) => {
return Math.floor(getRandomNum(minItems,maxItems));
//console.log("Range: "+min+"-"+max+" Number of items: "+num);
}
const createSingleDataset = () => {
const data = [];
const numOfItems = getNumberOfItems(minItems, maxItems);
for (let i = 0; i <= numOfItems; i++) {
const obj = {
"x": getRandomNum(min,max),
"y": getRandomNum(min,max)
}
data.push(obj);
}
//console.log(data);
return data;
}
const createDatasets = (n) => {
const data = [];
for(let i = 0; i < n; i++) {
data.push(createSingleDataset());
}
return data;
}
module.exports = createDatasets;