let rawData = {
One:[{month:1,count:10},{month:12,count:2}],
Two::[{month:1,count:14},{month:3,count:23}],
Three:[],
Four::[{month:1,count:10}],
};
// 拆分成想要的数据 ysdList、lydList、tzdList、bfdList都会包含12个对象,12个月份,而且对象没有顺序,没有的count赋值为0
// ysdList:[10,0,0,0,0,0,0,0,0,0,0,2]
// lydList:[14,0,23,0,0,0,0,0,0,0,0,0]
// tzdList:[0,0,0,0,0,0,0,0,0,0,0,0]
// bfdList:[10,0,0,0,0,0,0,0,0,0,0,0]
let targetData = {
ysdList: [],
lydList: [],
tzdList: [],
bfdList: [],
};
for (let i = 1; i < 13; i++) {
let ss = [];
if (!rawData.One) {
ss = [];
} else {
ss = rawData.One.filter((item) => {
return item.month == i;
});
}
if (ss.length <= 0) {
targetData.ysdList.push("0");
} else {
targetData.ysdList.push(ss[0].count + "");
}
let aa = [];
if (!rawData.Two) {
aa = [];
} else {
aa = rawData.Two.filter((item) => {
return item.month == i;
});
}
if (aa.length <= 0) {
targetData.lydList.push("0");
} else {
targetData.lydList.push(aa[0].count + "");
}
let bb = [];
if (!rawData.Three) {
bb = [];
} else {
bb = rawData.Three.filter((item) => {
return item.month == i;
});
}
if (bb.length <= 0) {
targetData.tzdList.push("0");
} else {
targetData.tzdList.push(bb[0].count + "");
}
let cc = [];
if (!rawData.Four) {
cc = [];
} else {
cc = rawData.Four.filter((item) => {
return item.month == i;
});
}
if (cc.length <= 0) {
targetData.bfdList.push("0");
} else {
targetData.bfdList.push(cc[0].count + "");
}
}
this.picList = { ...targetData };
月份数据统计,后台返回数据拆分12个对象,代表12个月份,而且月份没有顺序,没有的数据的赋值为0
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- 咱们的五月份数据出来了,在聊这个话题之前,我们回顾下,小号记忆承载3的5月17号的文章:怎么看我们四月份的数据[h...
- 日前,数据库流行度DB-Engines公布了三月份数据库榜单,Oracle、MySQL和SQL Server以及稳...