数据处理

      d变成dd
let d = { currentMonth: { "2022-11-01": 11, "2022-11-02": 43, "2022-11-03": 53, "2022-10-05": 23, }, lastMonth: { "2022-10-01": 4, "2022-10-04": 3, "2022-10-05": 13, "2022-11-01": 19, }, }; let dd = [ [ "2022-10-01", "2022-10-04", "2022-10-05", "2022-11-01", "2022-11-02", "2022-11-03", ], //本月 [0, 0, 23, 11, 43, 53], //上月 [4, 3, 13, 19, 0, 0], ]; const arr = [ ...Object.keys(d.currentMonth), ...Object.keys(d.lastMonth), ]; const newArr = [...new Set(arr)].sort(); const arr1 = [], arr2 = []; newArr.forEach((item) => { if (d.currentMonth[item]) arr1.push(d.currentMonth[item]); else arr1.push(0); if (d.lastMonth[item]) arr2.push(d.lastMonth[item]); else arr2.push(0); }); // console.log(1111, [newArr, arr1, arr2]);

 

posted @ 2022-11-28 17:04  abcByme  阅读(93)  评论(0编辑  收藏  举报