From 2af17190925dd442f4ba7d9d8ee97781d54bbbb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=98=E7=AB=8B=E6=A0=87?= <2658037827@qq.com> Date: Wed, 27 Dec 2023 10:04:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=9B=BE=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/dataBoard/renfang/cpts/fwgl.vue | 72 ++++----- src/views/dataBoard/renfang/index.vue | 172 +++++++++++----------- 2 files changed, 123 insertions(+), 121 deletions(-) diff --git a/src/views/dataBoard/renfang/cpts/fwgl.vue b/src/views/dataBoard/renfang/cpts/fwgl.vue index a861f9c8b..a18a551bc 100644 --- a/src/views/dataBoard/renfang/cpts/fwgl.vue +++ b/src/views/dataBoard/renfang/cpts/fwgl.vue @@ -100,16 +100,16 @@ export default { this.getData(); }) }, - watch: { - // orgId() { - // this.getData(); - // }, + watch: { + // orgId() { + // this.getData(); + // }, pandectData: { immediate: true, - deep:true, + deep: true, handler(newData) { this.pandectData = newData - this.iniPieChart(); + this.iniPieChart(); } } @@ -191,35 +191,36 @@ export default { }, // 获取饼状图 iniPieChart() { - this.$refs.pieChart.clear(); - // 获取pieChart配置 - this.pieOption = pieOption(); - const {pandectData} = this - // 设置三个配置值 - this.pieOption.title.text = pandectData.homeCount; - this.pieData = [ - {value: pandectData.selfStay, name: "自住"}, - {value: pandectData.rentOut, name: "出租"}, - {value: pandectData.vacantHouse, name: "闲置"}, - ]; - const temp = [...this.pieData,{value:pandectData.homeCount, name: "总数"}] - this.pieOption.series[0].data = this.pieData; - console.log(this.pieOption, 'this.pieOption.series') - this.$refs.pieChart.setOption(this.pieOption); - let than = this - let currentIndex = 0; + this.$nextTick(() => { + this.$refs.pieChart.clear(); + // 获取pieChart配置 + this.pieOption = pieOption(); + const {pandectData} = this + // 设置三个配置值 + this.pieOption.title.text = pandectData.homeCount; + this.pieData = [ + {value: pandectData.selfStay, name: "自住"}, + {value: pandectData.rentOut, name: "出租"}, + {value: pandectData.vacantHouse, name: "闲置"}, + ]; + const temp = [...this.pieData, {value: pandectData.homeCount, name: "总数"}] + this.pieOption.series[0].data = this.pieData; + console.log(this.pieOption, 'this.pieOption.series') + this.$refs.pieChart.setOption(this.pieOption); + let than = this + let currentIndex = 0; //饼状图点击事件 - this.$refs.pieChart.myChart.off('click').on('click', (param) =>{ //这里使用箭头函数代替function,this指向VueComponent - currentIndex = (currentIndex + 1) %temp.length; - const currentData =temp[currentIndex]; - const percentage = ((currentData.value / pandectData.homeCount) * 100).toFixed(2); - than.$refs.pieChart.myChart.setOption({ - title: { - text:currentData.name == '总数'?pandectData.homeCount: `${percentage}%`, - subtext: currentData.name, - } - }); - let index; + this.$refs.pieChart.myChart.off('click').on('click', (param) => { //这里使用箭头函数代替function,this指向VueComponent + currentIndex = (currentIndex + 1) % temp.length; + const currentData = temp[currentIndex]; + const percentage = ((currentData.value / pandectData.homeCount) * 100).toFixed(2); + than.$refs.pieChart.myChart.setOption({ + title: { + text: currentData.name == '总数' ? pandectData.homeCount : `${percentage}%`, + subtext: currentData.name, + } + }); + let index; //当前扇区的dataIndex index = param.dataIndex; //自己的操作,这里是点击跳转路由,并携带参数 @@ -228,6 +229,7 @@ export default { this.toListPage(index, param.name) } }); + }) // this.$refs.pieChart.hideLoading() }, @@ -487,9 +489,11 @@ export default { .margintop18 { margin-top: 18px; } + .pie-right { width: calc(100% - 200px); } + .new-number { display: flex; flex-wrap: wrap; diff --git a/src/views/dataBoard/renfang/index.vue b/src/views/dataBoard/renfang/index.vue index 25327804c..1e453c07a 100644 --- a/src/views/dataBoard/renfang/index.vue +++ b/src/views/dataBoard/renfang/index.vue @@ -1,9 +1,9 @@