我有3个数组内的数据,我需要将所有内容连接在一起,但我需要创建一个新数组,其中我有一个时间戳和x1,x2,x3,其中x1,x2,x3是每个数组的每个值。 / p>
像live = 1,重复= 2,passerBy = 3我将有数组= [timestamp,1,2,3]
我的数组是实时的,重复的和传递的值。
我不明白为什么数组inst满载值...总是打印[]
var live=[];
var repeated=[];
var passerBy=[];
var data=[];
live=[["2017-07-22T14:39:21.000Z","836"],["2017-07-22T14:44:21.000Z","207"],["2017-07-22T14:49:21.000Z","2006"],["2017-07-22T14:54:21.000Z","402"],["2017-07-22T14:59:22.000Z","198"],["2017-07-22T15:04:22.000Z","597"],["2017-07-22T15:16:22.000Z","180"],["2017-07-22T15:21:22.000Z","138"],["2017-07-22T15:26:22.000Z","293"]];
repeated=[["2017-07-22T14:39:21.000Z","18"],["2017-07-22T14:44:21.000Z","1"],["2017-07-22T14:49:21.000Z","1"],["2017-07-22T14:54:21.000Z","1"],["2017-07-22T14:59:22.000Z","1"],["2017-07-22T15:04:22.000Z","9"],["2017-07-22T15:16:22.000Z","1"],["2017-07-22T15:21:22.000Z","2"],["2017-07-22T15:26:22.000Z","1"]];
passerBy=[["2017-07-22T14:39:21.000Z","128"],["2017-07-22T14:44:21.000Z","518"],["2017-07-22T14:49:21.000Z","1258"],["2017-07-22T14:54:21.000Z","334"],["2017-07-22T14:59:22.000Z","128"],["2017-07-22T15:04:22.000Z","211"],["2017-07-22T15:16:22.000Z","104"],["2017-07-22T15:21:22.000Z","60"],["2017-07-22T15:26:22.000Z","380"]];
for(var l=0; l<live.length; l++){
for(var r=0; r<repeated.length; r++){
if(live[l][0] == repeated[r][0]){
var aux = [];
aux.push(live[l][0]);
aux.push(live[l][1]);
aux.push(repeated[r][1]);
data.push(aux);
}
}
console.log("data for 1 ",data);
}
console.log('array for 2', data);
for(var p=0; p<passerBy.length;p++){
for(var a=0; a<data.length; a++){
if(passerBy[p][0] == data[a][0]){
data[a].push(passerBy[p][1]);
}
}
}
console.log('array for 3', data);
for(var a=0; a<data.length;a++){
//array[a][0] = Date(array[a][0]).toString());
data[a][0]=new Date(Date.parse(data[a][0]));
}
console.log('array for 4', data);
我的日志:
2|wscontro | [2017-07-22 17:11:25.899] - debug: /opt/wscontroller/wscontroller-api/routes/logs LogsController f051b333-8f1f-4e65-9acc-e76470a87f47 getAllProbingRows live [["2017-07-22T15:16:22.000Z","180"],["2017-07-22T15:21:22.000Z","138"],["2017-07-22T15:26:22.000Z","293"],["2017-07-22T15:31:22.000Z","1145"],["2017-07-22T15:36:22.000Z","205"],["2017-07-22T15:42:22.000Z","306"],["2017-07-22T15:47:23.000Z","52"],["2017-07-22T15:52:23.000Z","141"],["2017-07-22T15:57:23.000Z","694"]]
2|wscontro | [2017-07-22 17:11:25.899] - debug: /opt/wscontroller/wscontroller-api/routes/logs LogsController f051b333-8f1f-4e65-9acc-e76470a87f47 getAllProbingRows repeated [["2017-07-22T15:16:22.000Z","1"],["2017-07-22T15:21:22.000Z","2"],["2017-07-22T15:26:22.000Z","1"],["2017-07-22T15:31:22.000Z","1"],["2017-07-22T15:36:22.000Z","1"],["2017-07-22T15:42:22.000Z","1"],["2017-07-22T15:47:23.000Z","1"],["2017-07-22T15:52:23.000Z","1"],["2017-07-22T15:57:23.000Z","1"]]
2|wscontro | [2017-07-22 17:11:25.900] - debug: /opt/wscontroller/wscontroller-api/routes/logs LogsController f051b333-8f1f-4e65-9acc-e76470a87f47 getAllProbingRows passerBy [["2017-07-22T15:16:22.000Z","104"],["2017-07-22T15:21:22.000Z","60"],["2017-07-22T15:26:22.000Z","380"],["2017-07-22T15:31:22.000Z","230"],["2017-07-22T15:36:22.000Z","117"],["2017-07-22T15:42:22.000Z","370"],["2017-07-22T15:47:23.000Z","145"],["2017-07-22T15:52:23.000Z","185"],["2017-07-22T15:57:23.000Z","127"]]
2|wscontro | array for 1 []
2|wscontro | array for 2 []
2|wscontro | array for 3 []
2|wscontro | array for 4 []