diff --git a/src/components/berth/index.vue b/src/components/berth/index.vue index bf75002..4972754 100644 --- a/src/components/berth/index.vue +++ b/src/components/berth/index.vue @@ -44,20 +44,35 @@ } }, mounted() { -// var i= 1,_self=this; -// setInterval(function(){ -// i ++; -// _self.free +=i;//动态改变值测试---通过 -// _self.have +=i; -// },2000) + this.axios.post('urban/intelligence/berth/queryBerthStatisticByOrgIds',{ + orgIds: [10003,10005] + }).then((response)=>{ + let data = response.data.data + console.log(data) + this.berthTotal = common.formatNumToStr(data.allBerthNum) + this.free = data.freeBerthNum + this.have = data.isOccupyBertnNum + + this.pieChartOption.seriesData[0].value = data.isOccupyBertnNum + this.pieChartOption.seriesData[1].value = data.freeBerthNum + let pieChartOption = this.pieChartOption + //占有率 + this.pieChart=this.createPie(pieChartOption); + window.addEventListener('resize', function() { + this.pieChart.resize() + }.bind(this)); + + // let barChartOption = this.barChartOption + // this.barChart=this.createBar(barChartOption); + // window.addEventListener('resize', function() { + // this.barChart.resize() + // }.bind(this)); + }).catch((response)=>{ + console.log(response); + }) //this.createLine(); //总收入 - this.berthTotal=this.formatNumToStr(); - //占有率 - this.pieChart=this.createPie(); - window.addEventListener('resize', function() { - this.pieChart.resize() - }.bind(this)); + }, methods: { /* @@ -69,12 +84,13 @@ /* * 泊位占比 * */ - createPie(){ + createPie(pieChartOption){ //debugger; - let root=this.$options.data().pieChartOption; + let root=pieChartOption; let pieChart = echarts.init(document.querySelector('.app-berthBox .berthPie')); //占有率 let zyPercent= (root.seriesData[0].value / (root.seriesData[0].value + root.seriesData[1].value));//注意顺序!!! + console.log(zyPercent) let seriesData=root.seriesData; const option={ // grid: { @@ -115,7 +131,7 @@ value: 0, label: { normal: { - formatter: (Math.round(zyPercent*10)/10)*100 + '%',//小数点后一位 + formatter: (zyPercent*100).toFixed(1) + '%',//小数点后一位 textStyle: { color: '#fe8b53', fontSize: 18,