var app = new Vue({
el:"#app",
data:function(){
return {
list:[]
}
},
methods:{
getList(){
let self = this;
let [adMax,deMax,leftLen,rightLen,sum] = [0,0,0,0,0,0];
let list = [
{ad:{title:"家居建",value:100},de:{title:"人流指数",value:50}},
{ad:{title:"外国餐厅",value:150},de:{title:"专科医院",value:70}},
{ad:{title:"中餐厅",value:80},de:{title:"停车场",value:20}},
{ad:{title:"中餐厅",value:20},de:{title:"停车场",value:90}},
{ad:{title:"中餐厅",value:300},de:{title:"停车场",value:20}},
{ad:{title:"中餐厅",value:250},de:{title:"停车场",value:130}},
{ad:{title:"中餐厅",value:90},de:{title:"停车场",value:90}},
{ad:{title:"中餐厅",value:0},de:{title:"停车场",value:200}},
]
list.forEach(val=>{
if(val.ad.value > adMax) adMax = val.ad.value;
if(val.de.value > deMax) deMax = val.de.value;
})
sum = adMax + deMax;
leftLen = (adMax / sum) * 100;
rightLen = (deMax / sum) * 100;
let arr = [];
self.list = list.map(val=>{
val['leftLen'] = leftLen;
val['rightLen'] = rightLen;
val['adPercentage'] = (val.ad.value / adMax) * 100;
val['dePercentage'] = (val.de.value / deMax) * 100;
return val;
})
}
},
mounted(){
let self = this;
setTimeout(()=>{
self.getList();
},1000)
}
})