From f81ac447f6b928fd29a660f74071766c7f2f08f5 Mon Sep 17 00:00:00 2001 From: shijingjing <1789544664@qq.com> Date: Fri, 30 Dec 2022 15:56:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=85=E6=B0=91=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppDataStatistics/components/resident.vue | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/project/saas/AppDataStatistics/components/resident.vue b/src/project/saas/AppDataStatistics/components/resident.vue index d4eeee74..0e13e596 100644 --- a/src/project/saas/AppDataStatistics/components/resident.vue +++ b/src/project/saas/AppDataStatistics/components/resident.vue @@ -45,6 +45,7 @@ export default { specialPeople: {}, specialFlag: true, ageArray: [], + ageRange: [], ageFlag: true, sexArray: [], sexFlag: true, @@ -65,24 +66,25 @@ export default { if(res?.data) { this.data = res.data this.specialPeople = res.data.特殊人群 - let specialArr = Object.values(this.specialPeople) - this.specialFlag = !specialArr.every(e=> e==0) + this.$nextTick(()=> { + let specialArr = Object.values(this.specialPeople) + this.specialFlag = !specialArr.every(e=> e==0) + }) this.ageArray = res.data.年龄层次.map(v=> v.v2) + this.ageRange = res.data.年龄层次.map(v=> v.v1) this.ageFlag = !this.ageArray.every(e=> e==0) this.sexArray = res.data.男女比例.map(v=> v.v2) this.sexFlag = !this.sexArray.every(e=> e==0) - this.$nextTick(()=> { - this.getSpecialEcharts() - this.getAgeEcherts(this.ageArray) - this.getAgeProportion() - }) + this.getSpecialEcharts() + this.getAgeProportion() + this.getAgeEcherts(this.ageArray) } }) }, // 特殊人群 getSpecialEcharts() { let specialDom = document.getElementById('specialEcharts'); - let myChart = echarts.init(specialDom); + let mySpecialChart = echarts.init(specialDom); let option = { title: { zlevel: 0, @@ -142,17 +144,17 @@ export default { } ] }; - option && myChart.setOption(option); + option && mySpecialChart.setOption(option); }, // 年龄分布 getAgeEcherts(ageArray) { let ageDom = document.getElementById('ageEcharts'); - let myChart = echarts.init(ageDom); + let myAgeChart = echarts.init(ageDom); let option; option = { xAxis: { type: 'category', - data: ['10以下', '10-18', '18-65', '65-80', '80以上'] + data: this.ageRange, }, yAxis: { type: "value", @@ -189,7 +191,7 @@ export default { } ] }; - option && myChart.setOption(option); + option && myAgeChart.setOption(option); }, // 男女比例 getAgeProportion() {