orderDistributeChart.vue
2.99 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
<!-- 球形echarts -->
<template>
<div
id="order-distribute-chart"
></div>
</template>
<script>
import echarts from 'echarts'
import { orderDistributeStatic } from '../static'
export default {
name: 'OrderAccountChart',
data() {
return {
}
},
methods: {
// 初始化列表
initial() {
const myChart = echarts.init(
document.getElementById('order-distribute-chart')
)
const data = orderDistributeStatic
data.sort(function (a, b) {
return a.value - b.value
})
// 订单分布echarts图表数据
const barOption = {
tooltip: {
borderColor: '#EBEEF5',
borderWidth: 1,
padding: [5, 16, 5, 14],
trigger: 'axis',
backgroundColor: 'rgba(255,255,255,0.96)',
formatter: (params) => {
return (
'<span style="color:#818693;font-size:12px;margin-right:25px;margin-bottom:4px;display:inline-block">省份:</span>' +
'<span style="color:#20232A;font-size:12px;display:inline-block">' +
params[0].name +
'</span>' +
'<br />' +
('<span style="color:#818693;font-size:12px;margin-bottom:4px;display:inline-block">订单总量:</span>' +
'<span style="color:#20232A;font-size:12px;display:inline-block;float:right">' +
params[0].data +
'笔' +
'</span>')
)
}
},
xAxis: {
type: 'value',
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
margin: 17
},
splitLine: {
lineStyle: {
color: '#EBEEF5'
}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '0%',
height: '100%',
containLabel: true
},
yAxis: {
type: 'category',
axisLabel: {
// rotate: 30,
interval: 0,
fontSize: 11,
color: '#20232A'
},
axisLine: {
lineStyle: {
color: '#EBEEF5'
}
},
axisTick: {
show: false
},
data: data.map(function (item) {
return item.name
})
},
animationDurationUpdate: 1000,
series: {
type: 'bar',
id: 'population',
data: data.map(function (item) {
return item.value
}),
universalTransition: true,
barWidth: 5,
itemStyle: {
color: '#E15536'
}
}
}
myChart.setOption(barOption)
// 当窗口或者大小发生改变时执行resize,重新绘制图表
window.addEventListener('resize', function() {
myChart.resize()
})
}
}
}
</script>
<style scoped>
#line-manage-chart {
height: 400px;
}
</style>