zrelation.vue
5.96 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
96
97
98
99
100
101
102
103
104
105
106
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
147
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
<!-- 楼层客流综合指标分布 -->
<template>
<div>
<el-row class="ipart ipart2" :gutter="12" v-loading="loading">
<el-col :span="12">
<div class="ipage_top">
<div class="tit"><img :src="bindIcon('renyuan')"/>{{title||chartData.title}}</div>
<div class="acts"></div>
</div>
<p class="ctitle">{{$t('iPage.stayaverage')}}<span v-html="countVal"></span></p>
<div class="ichart">
<bar-chart @emitChart="chartClick" :cdata="chartData" tval="hbar"></bar-chart>
</div>
</el-col>
<el-col :span="12" v-loading="loading2">
<div class="ipage_top">
<div class="tit"><img :src="bindIcon('renyuan')"/>{{$t('iPage.stayagepercent')}}</div>
</div>
<span class="ctitle">{{barTitle}}</span>
<stack-chart :cdata="chartData2"></stack-chart>
</el-col>
</el-row>
</div>
</template>
<script>
import mixin from './mixin';
import mallData from '@/components/Echarts/data';
import _ from 'underscore';
const chartsConfig = {
zone_detention_gender:{ //默认 //年龄统计
otherConf:{
_color:['#3F8CFF','#FFD48A'],
doubleYaxis: true,
isSwapY: true
// hasYaxisName:false,
}
},
zone_detention_statistics:{
_color:['#90BDFF'],
reverseAxis:true,
labelPosition:'right',
grid:{
top: 40, right:20, bottom: 20, left: 40
},
showCount:false,
usePercent:true
}
};
export default {
mixins: [mixin],
data() {
return {
loading:true,
loading2:false,
chartData2:{},
countVal:'',
barTitle:''
}
},
created() {
},
methods: {
loadChartData(params){
this.chartId = this.getChartId(this.ckey);
this.loading = true;
if(this.chartId){
this.ajaxModuleData().then(data=>{
this.setChartData(data);
});
}else{
this.setChartData();
}
},
chartClick({name,dataIndex}){
this.setCurrenRose({name,dataIndex});
},
setChartData(data){
let countVal = _.findWhere(data.series,{name:'avg'}).data[0];
data.series = _.filter(data.series,item=>item.name!='avg');
if(countVal||countVal==0){
this.countVal = typeof countVal=='string'?countVal.replaceAll(/\d+/g,'<em>$&</em>'):`<em>${countVal}</em>${this.$t('iPage.number')}}`;
}
let floorData = JSON.parse(JSON.stringify({...data,yaxis:data.xaxis}));
floorData.series[0].data = floorData.series[0].data.map((value,i)=>{
if(value instanceof Object)return value;
let item = {
value:value,
/*label:{
formatter:'{a}{b}{c}{d}'
},*/
itemStyle:{
color:'#90BDFF',
}
}
return item;
})
this.maxNum = (_.max(_.pluck(floorData.series[0].data,'value')))*1.35;
floorData.series[1] = {
name: 'background',
type: 'bar',
label:{
show:false
},
itemStyle: {
barBorderRadius: 0,
color: '#f7f6f9'
},
emphasis:{
itemStyle:{
color: '#f7f6f9'
}
},
barGap: '-100%',
z: 0,
data: new Array(floorData.series[0].data.length).fill(this.maxNum)
};
this.chartData = Object.assign({},floorData,{
otherConf:{
reverseAxis:true,
labelPosition:'right',
usePercent:true,
hideLoading:true
}
});
this.$nextTick(()=>{
setTimeout(()=>{
let dataIndex = 0;
this.chartClick({dataIndex,name:floorData.yaxis.data[dataIndex]});
this.loading = false;
},200)
})
},
setCurrenRose({name,dataIndex}){
let that = this,chartData = Object.assign({},this.chartData);
chartData.series[1].data = chartData.series[1].data.map((item,idx)=>{
if(idx!=dataIndex)return this.maxNum;
return {
value:this.maxNum,
itemStyle:{
borderColor:'#90BDFF',
borderWidth:2,
shadowColor:'#90BDFF',
shadowBlur:10
}
};
});
this.chartData = Object.assign({},chartData,chartsConfig[this.ckey]);
this.loadRoseChartData({name,dataIndex});
},
loadRoseChartData({name,dataIndex}){
this.barTitle = name;
//this.loading2 = true;
let key = 'zone_detention_gender'
let chartId = this.getChartId(key);
this.$api.ipageReport.bodyReport({...this.params,chartIds:chartId,index:dataIndex}).then(res=>{
let { data } = res.data;
let charData2 = data[key];
this.chartData2 = Object.assign({},charData2,chartsConfig[key]);
//this.loading2 = false;
})
}
}
}
</script>
<style lang="less" scoped>
.ctitle{
position:absolute;
left:0%;
top:8%;
font-size: 14px;
z-index: 9;
em{
font-size: 16px;
font-weight: 600;
font-style:normal;
margin-left: 5px;
margin-right: 2px;
}
}
</style>