let data = [
{
risk: "聽力",?
agegroup: "60歲以下",?
sort: 1,?
count: 21
},?
{
risk: "聽力",?
agegroup: "60-70歲",?
sort: 2,?
count: 36
},?
{
risk: "聽力",?
agegroup: "70-80歲",?
sort: 3,?
count: 19
},?
{
risk: "聽力",?
agegroup: "80-90歲",?
sort: 4,?
count: 2
},?
{
risk: "尿失禁",?
agegroup: "60歲以下",?
sort: 1,?
count: 1
},?
{
risk: "尿失禁",?
agegroup: "60-70歲",?
sort: 2,?
count: 9
},?
{
risk: "尿失禁",?
agegroup: "70-80歲",?
sort: 3,?
count: 7
},?
{
risk: "尿失禁",?
agegroup: "80-90歲",?
sort: 4,?
count: 2
},?
{
risk: "抑郁狀況",?
agegroup: "60-70歲",?
sort: 2,?
count: 1
},?
{
risk: "移動(dòng)能力",?
agegroup: "60-70歲",?
sort: 2,?
count: 2
},?
{
risk: "營養(yǎng)狀況",?
agegroup: "60歲以下",?
sort: 1,?
count: 4
},?
{
risk: "營養(yǎng)狀況",?
agegroup: "60-70歲",?
sort: 2,?
count: 11
},?
{
risk: "營養(yǎng)狀況",?
agegroup: "70-80歲",?
sort: 3,?
count: 5
},?
{
risk: "營養(yǎng)狀況",?
agegroup: "80-90歲",?
sort: 4,?
count: 1
},?
{
risk: "視力",?
agegroup: "60歲以下",?
sort: 1,?
count: 18
},?
{
risk: "視力",?
agegroup: "60-70歲",?
sort: 2,?
count: 34
},?
{
risk: "視力",?
agegroup: "70-80歲",?
sort: 3,?
count: 12
},?
{
risk: "視力",?
agegroup: "80-90歲",?
sort: 4,?
count: 1
},?
{
risk: "認(rèn)知功能",?
agegroup: "60歲以下",?
sort: 1,?
count: 5
},?
{
risk: "認(rèn)知功能",?
agegroup: "60-70歲",?
sort: 2,?
count: 22
},?
{
risk: "認(rèn)知功能",?
agegroup: "70-80歲",?
sort: 3,?
count: 3
},?
{
risk: "跌倒",?
agegroup: "60歲以下",?
sort: 1,?
count: 2
},?
{
risk: "跌倒",?
agegroup: "60-70歲",?
sort: 2,?
count: 7
},?
{
risk: "跌倒",?
agegroup: "70-80歲",?
sort: 3,?
count: 10
},?
{
risk: "跌倒",?
agegroup: "80-90歲",?
sort: 4,?
count: 1
}
]
// let arr = [
// ? {type:'apple',money:50},
// ? {type:'apple',money:10},
// ? {type:'banana',money:10},
// ? {type:'orange',money:10},
// ? {type:'orange',money:10},
// ? {type:'apple',money:10},
// ]
var nameArr = [...new Set(data.map(i =>i.risk))];//名稱集合數(shù)組去重
let list=[];
nameArr.forEach(v=>{
? let filterlist = data.filter(a=>v==a.risk);
? list.push(filterlist)
});
let chartValues=[];
list.forEach((item,index)=>{
? let moneyAdd = item.reduce((total, g)=>{
return total + Number(g.count)
? }, 0);
? chartValues.push(moneyAdd)
})
console.log('====outArr12112===',JSON.stringify(chartValues))
最終輸出
nameArr =["聽力","尿失禁","抑郁狀況","移動(dòng)能力","營養(yǎng)狀況","視力","認(rèn)知功能","跌倒"]
chartValues=[78,19,1,2,21,65,30,20]
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧
新聞標(biāo)題:js遍歷數(shù)組重復(fù)值和數(shù)組中對象重復(fù)值-創(chuàng)新互聯(lián)
網(wǎng)頁地址:http://jinyejixie.com/article22/hgjjc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、建站公司、品牌網(wǎng)站制作、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站營銷、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容