我有一个折线图Documentation。但它与另一条线重叠,它们具有相同的数据点集。
处理这种情况的任何解决方案。
答案 0 :(得分:1)
迭代对象属性并生成结果数组。
var obj = {
"rules": [{"interval": "Week 1","count": 0},{"interval": "Week 2","count": 0}],
"assets": [{"interval": "Week 1","count": 1},{"interval": "Week 2","count": 0}]
};
var res = Object.keys(obj) // get all object keys
.reduce(function(arr, k) { // iterate over keys array and generate result array
obj[k].forEach(function(v) { // iterate over inner property value array
arr.push(Object.assign({ // generate the object element
name: k
}, v));
});
return arr; // return the array reference
}, []);
console.log(res);