Order.vue
3.68 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
<template>
<div
class='order-data'
ref='data'
>
</div>
</template>
<script type='text/ecmascript-6'>
import map_code from '@p/map/mapId.js'
const lineColor = ['#f91e39', '#ffba34', '#2691ff', '#00c0c2']
export default {
name: 'Order',
data () {
return {
}
},
props: {
list: {
type: Array,
default: []
}
},
mounted () {
},
watch: {
'list' (n, o) {
if (n) {
this.createdCanvas()
}
}
},
methods: {
createdCanvas () {
let arr = this.list
let list = []
let data = []
arr.forEach(e => {
data.push(e.value)
for (const key in map_code) {
if (map_code[key] == e.prov_code) {
list.push({
name: key
})
}
}
})
arr.forEach((e, index) => {
list[index].value = (e.value / arr[0].value).toFixed(2) * 100
})
let canvas = echarts.init(this.$refs.data)
let options = {
xAxis: [{
type: 'value',
min: 0,
max: 100,
gridIndex: 0,
axisTick: { show: false, inside: false },
axisLabel: { show: false },
axisLine: {// Y轴轴线样式
show: false,
},
splitLine: {
show: false
}
},
{
gridIndex: 1,
show: false,
}],
yAxis: [{
type: 'category',
gridIndex: 0,
inverse: true,
data: data,
axisTick: { show: false },
axisLabel: { show: false },
axisLine: { show: false }
},
{
gridIndex: 1,
type: 'category',
inverse: true,
position: 'left',
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
show: true,
textStyle: {
color: '#ffffff',
fontSize: 24,
align: 'left'
},
},
data: data
}],
grid: [{
top: 30,
bottom: 0,
width: '180px',
left: '165px',
gridIndex: 0,
containLabel: true,
},
{
show: false,
left: '395px',
top: 30,
bottom: 0,
gridIndex: 1,
width: '0%',
},],
series: [
{
type: 'bar',
barWidth: '10',
gridIndex: 0,
itemStyle: {
show: true,
color: val => {
return lineColor[val.dataIndex]
},
barBorderRadius: 4,
},
data: list
},
{
name: 'border',
type: 'bar',
barWidth: '10',
label: {
color: '#ffffff',
fontSize: 24,
position: 'left',
offset: [-38, 0],
show: true,
formatter: val => {
let label = ''
list.forEach((e, ind) => {
if (val.dataIndex == ind) label = `${ind + 1}\t\t\t${e.name}`
})
return label
}
},
itemStyle: {
normal: {
barBorderRadius: 4,
color: 'rgba(44, 145, 255, 0.1)' //rgba设置透明度0.14
}
},
barGap: '-100%',
z: 0,
data: [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]
}
]
}
canvas.setOption(options)
}
}
}
</script>
<style scoped lang='scss'>
.order-data {
width: 100%;
height: 100%;
}
</style>