How to take out the data of Plan_ADEP and Plan_ADES in the picture and convert it into the data format shown in the picture above? ?
高洛峰2017-05-19 10:11:07
var contents = what.contents, //先获取数据
tempArr = [];
for( var i = 0,content; content = contents[i++]; ){
var arr = [];
for( var key in content ){
var obj_1 = {},
obj_2 = {};
if(key == "Plan_ADEP"){
obj_1[key] = content[key];
arr.push(obj_1);
}
if(key == "Plan_ADES"){
obj_2[key] = content[key];
arr.push(obj_2);
}
}
tempArr.push(arr);
//tempArr就是你要的值
}
//或者这样写更简单:
/*
for( var i = 0,content; content = contents[i++]; ){
var arr = [],obj_1 = {},obj_2 = {};
obj_1.Plan_ADEP = content.Plan_ADEP;
obj_2.Plan_ADES = content.Plan_ADES;
arr.push(obj_1);
arr.push(obj_2);
tempArr.push(arr);
//tempArr就是你要的值
}
*/
I don’t know if I understood you wrong
为情所困2017-05-19 10:11:07
var GZData=[];
contents.map(function(item){
GZData.push([{name:"广州"},{name:item.Plan_ADEP,value:item.Plan_ACID_Three}]);
})
console.log(GZData)
Note: contents. is the contents array in the data of your picture. You take it out; then GZData is the format you want. I don’t know.
{name: "Guangzhou"}, {name: item.Plan_ADEP, value: item.Plan_ACID_Three} Which one you want to target, you can use item to correspond