sankey2.vue
3.54 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
<!-- 性别统计 -->
<template>
<div>
<!-- 顶部区域 S-->
<div class="ipage_top">
<div class="tit"><img :src="bindIcon('caigou1')"/>{{title||chartData.title}}</div>
</div>
<el-row class="ichart" v-loading="loading">
<el-col :span="12" :style="{opacity:isEmpty?0:1}">
<sankey-chart :cdata="chartData2" tval="sankey2"></sankey-chart>
<p v-show="!isEmpty" class="ictit">客流流入</p>
</el-col>
<el-col :span="12" :style="{opacity:isEmpty?0:1}">
<sankey-chart :cdata="chartData" tval="sankey3"></sankey-chart>
<p v-show="!isEmpty" class="ictit">客流流出</p>
</el-col>
<div class="empty" v-show="isEmpty">
<img src="@/assets/img/no_data.png">
<p>{{$t('pholder.nodata')}}</p>
</div>
</el-row>
</div>
</template>
<script>
import mixin from './mixin';
import mallData from '@/components/Echarts/data';
/**********************************************************/
const chartsConfig = {
default:{ //默认
otherConf:{
orient:'horizontal'
}
}
};
/*******************************************************/
export default {
mixins: [mixin],
data() {
return {
isEmpty:false,
loading:true,
configObj:{},
chartData2:{}
}
},
created() {
},
methods: {
getChartsConfig(){
return chartsConfig;
},
loadChartData(params){
this.loading = true;
this.chartId = this.getChartId(this.ckey);
if(this.chartId){
this.ajaxModuleData().then(data=>{
this.setChartData(data);
});
}
},
setChartData(data){
this.loading = false;
if(!data||data.series.length==0){
this.isEmpty = true;
return;
}
this.isEmpty = false;
data.series.forEach((item,idx)=>{
item.type = 'sankey';
let [idata,links] = [[],[]];
item.data.forEach(it=>{
it.source = String(it.source);
links.push(JSON.parse(JSON.stringify(it)));
idata.push({name:item.name=='from'?it.source:it.target})
});
if(item.name=='from'){
idata.unshift({name:item.data[0].target});
item.data = idata;
item.links = links;
let chartData = {
series:[JSON.parse(JSON.stringify(item))]
}
this.chartData2 = Object.assign({},chartData,{
otherConf:this.configObj.otherConf||{}
});
}else if(item.name=='to'){
idata.unshift({name:item.data[0].source});
item.data = idata;
item.links = links;
let chartData = {
series:[JSON.parse(JSON.stringify(item))]
}
this.chartData = Object.assign({},chartData,{
otherConf:this.configObj.otherConf||{}
});
}
})
}
}
}
</script>
<style lang="less" scoped>
.ictit{
position:absolute;
left: 50%;
transform: translateX(-50%);
color: #000;
font-size: 14px;
bottom:0
}
</style>