areaCharts.vue
4.07 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
<template>
<div class="_chart">
<div class="_chartTitle">
<h3>地域分布</h3>
<span>展示近30天销售地域分布数据</span>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div id="yohoTop" style="width: 500px;height:400px"></div>
</div>
<div class="col-sm-6">
<div id="shopTop" style="width: 500px;height:400px"></div>
</div>
</div>
</template>
<script type="text/javascript">
var echarts = require('echarts');
import util from 'util';
module.exports = {
data:function() {
return {}
},
ready:function(){
this.getData();
},
methods:{
getData(){
this.$http.post("/chart/getShopTopArea", {
dateId: util.dateFormat(new Date(),"YYYYMMdd")
}).then(function (response) {
var data = response.data.data;
//全站销售地域
var yohoTop = echarts.init(document.getElementById('yohoTop'));
var yohoOption = this.getXOption(data.yoho.x, data.yoho.y, "全站销售地域top10:");
yohoTop.setOption(yohoOption);
//店铺销售地域
var shopTop = echarts.init(document.getElementById('shopTop'));
var shopOption = this.getXOption(data.shop.x, data.shop.y, "店铺销售地域top10:");
shopTop.setOption(shopOption);
});
},
getXOption(provinces, data, title){
var option = {
title : {
show: true,
text: title
},
xAxis : [
{
type:'value',
show:false
}
],
yAxis : [
{
type:'category',
data:provinces,
axisLine:{
show:false
},
axisTick:{
show:false
},
splitLine:{
show:false
}
}
],
series : [
{
name:'销量',
type:'bar',
data:data,
itemStyle: {
normal: {
color: '#999999',
label : {
show: true,
position: 'right',
textStyle:{
color:"#585858",
align:"right"
},
formatter:function (params) {
return params.value + '%';
}
}
}
}
}
]
};
return option;
}
}
}
</script>
<style>
._chart{
clear: both;
width: 100%;
font-family: 'microsoft yahei';
color: #585858;
}
._chartTitle{
width: 100%;
padding: 0 20px;
height: 40px;
background-color: #ccc;
}
._chartTitle h3{
float: left;
line-height: 40px;
font-size: 20px;
margin: 0;
font-weight: bold
}
._chartTitle span{
display: block;
float: right;
line-height: 40px;
font-size: 14px;
}
</style>