22fb20b3
songchongxian
城市停车运营监控
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<template>
<div class="app-berthBox">
<div class="theme-card">
<div class="title"><span>泊位</span></div>
<div class="content">
<div class="topBox eleVerHorCenter-flex">
<span class="eleText">总计</span>
<div class="eleMarginLeft" v-html="berthTotal"></div>
</div>
<div class="bottomBox eleVerHorCenter-flex">
<div class="bottomBoxLeft"> <div class="berthPie"></div> </div>
<div class="bottomBoxRight">
<table class="havefreeTb">
<tr><td> <div class="free">{{ free }}</div></td><td> <div class="freeText">空余</div></td></tr>
<tr><td> <div class="have">{{ have }}</div></td><td> <div class="haveText">占有</div></td></tr>
</table>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import common from '../../api/common';
import echarts from 'echarts'
|
e52cf1d6
liuqimichale
添加丹阳
|
27
|
import { berthAddress, berthAddressDY } from '../../api/api'
|
22fb20b3
songchongxian
城市停车运营监控
|
28
29
30
31
|
export default {
name: "berth",
data() {
return {
|
74b5bee2
liuqimichale
全局 接口参数
|
32
|
demo:'',//示例
|
22fb20b3
songchongxian
城市停车运营监控
|
33
|
berthTotal:"",//泊位总数
|
8dcd7f64
liuqimichale
api 接口封装 news
|
34
35
|
free:'',//空余
have:'',//占有
|
22fb20b3
songchongxian
城市停车运营监控
|
36
37
38
39
|
pieChart: {},
name: '饼图',
pieChartOption:{
seriesData:[
|
8dcd7f64
liuqimichale
api 接口封装 news
|
40
41
|
{name:"占有",value:''},
{name:"空余",value:''}
|
22fb20b3
songchongxian
城市停车运营监控
|
42
43
44
45
46
|
]
}
}
},
mounted() {
|
8dcd7f64
liuqimichale
api 接口封装 news
|
47
|
this.onLoad()
|
22fb20b3
songchongxian
城市停车运营监控
|
48
49
|
},
methods: {
|
8dcd7f64
liuqimichale
api 接口封装 news
|
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
onLoad() {
berthAddress({
orgIds: this.GLOBAL.paramsvariables
}).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));
}).catch((response)=>{
console.log(response);
})
|
e52cf1d6
liuqimichale
添加丹阳
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
this.$axios.all(
[
berthAddress({ orgIds: this.GLOBAL.paramsvariables}),
berthAddressDY({ orgIds: this.GLOBAL.paramsvariables})
]
)
.then(this.$axios.spread((acctWX, acctDY) => {
let WXdata = acctWX.data.data
let DYdata = acctDY.data.data
this.berthTotal = common.formatNumToStr(WXdata.allBerthNum+DYdata.allBerthNum)
this.free = WXdata.freeBerthNum+DYdata.freeBerthNum
this.have = WXdata.isOccupyBertnNum+DYdata.isOccupyBertnNum
this.pieChartOption.seriesData[0].value = WXdata.isOccupyBertnNum+DYdata.isOccupyBertnNum
this.pieChartOption.seriesData[1].value = WXdata.freeBerthNum+DYdata.freeBerthNum
let pieChartOption = this.pieChartOption
//占有率
this.pieChart=this.createPie(pieChartOption);
window.addEventListener('resize', function() {
this.pieChart.resize()
}.bind(this));
}))
|
22fb20b3
songchongxian
城市停车运营监控
|
96
97
98
99
|
},
/*
* 泊位占比
* */
|
be7e8a78
liuqimichale
泊位
|
100
|
createPie(pieChartOption){
|
22fb20b3
songchongxian
城市停车运营监控
|
101
|
//debugger;
|
be7e8a78
liuqimichale
泊位
|
102
|
let root=pieChartOption;
|
22fb20b3
songchongxian
城市停车运营监控
|
103
104
105
|
let pieChart = echarts.init(document.querySelector('.app-berthBox .berthPie'));
//占有率
let zyPercent= (root.seriesData[0].value / (root.seriesData[0].value + root.seriesData[1].value));//注意顺序!!!
|
be7e8a78
liuqimichale
泊位
|
106
|
console.log(zyPercent)
|
22fb20b3
songchongxian
城市停车运营监控
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
let seriesData=root.seriesData;
const option={
// grid: {
// top: '0%',left: '0%',
// right: '0%',bottom: '0%'
// },
grid: {
top: 13,left: 10,
right: 10,bottom: 10,
containLabel: true
},
title: { show:false },
tooltip: {show:false},
series: [{
name: 'pie',type: 'pie',
center: ['50%', '50%'],
radius: ['75%', '90%'],
hoverAnimation: false,
color: ['#FFB704','#02ABFF'],//占有黄色
label: {show:false},
itemStyle: {
normal: {
label: {show: false},
labelLine: {show: false},
shadowBlur: 40,
shadowColor: 'rgba(40, 40, 40,0.5)',
}
},
data: seriesData
},
//内环
{
name: '', type: 'pie',
clockWise: true,hoverAnimation: false,
radius: ['90%', '90%'],
label: { normal: { position: 'center' }},
data: [{
value: 0,
label: {
normal: {
|
be7e8a78
liuqimichale
泊位
|
147
|
formatter: (zyPercent*100).toFixed(1) + '%',//小数点后一位
|
22fb20b3
songchongxian
城市停车运营监控
|
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
textStyle: {
color: '#fe8b53',
fontSize: 18,
fontWeight: 'normal'
}
}
}
}, {
tooltip: {show: false},
label: {
normal: {
formatter: '\n占有',
textStyle: {
color: '#bbeaf9',fontSize: 12
}
}
}
}]
}
]
};
pieChart.setOption(option);
return pieChart;
}
},
}
</script>
<style scoped lang="scss">
.app-berthBox {
width: 100%;
.theme-card{
height: 100%;
}
.berthPie{
position: absolute;
margin: 0 auto;
top:0;
bottom: 0;
left:0;
width: 100%;
height: 100%;
}
.bottomBoxLeft,.bottomBoxRight{
display: inline-block;
width: 50%;
height:100%;
border:0px solid red;
position: relative;
}
.havefreeTb{
height:100%;width: 100%;
}
.havefreeTb td{
text-align: center;
vertical-align: middle;
}
.havefreeTb >tr> td:last-child{
font-size: 12px;text-align: left;
}
/*空余*/
.havefreeTb .free{
background-image: -webkit-linear-gradient(bottom, #00CAFE, #2772F4);
-webkit-background-clip:text;
-webkit-text-fill-color:transparent;
font-size: 24px;
}
/*占有*/
.havefreeTb .have{
background-image: -webkit-linear-gradient(bottom, #FFBA00, #FF8100);
-webkit-background-clip:text;
-webkit-text-fill-color:transparent;
font-size: 24px;
}
.freeText,.haveText{
margin-top:5px;
}
}
</style>
|