options.js
7.22 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2022-10-25 10:46:24
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2022-10-27 14:31:44
* @FilePath: \dj-data-view\src\components\barOptions.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
function getBarOptions(obj) {
var options = {
xAxis: {
type: 'category',
axisLabel: {
color: '#fff',
fontSize: '0.8em',
rotate: obj.rotate
},
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLine: {
show: false
},
data: ['广汽本田', '广汽丰田', '一汽奥迪', '宝马', '奔驰', '其他']
},
grid: {
left: '8%',
right: '6%',
top: '3%',
bottom: obj.rotate ? '4%' : '12%',
containLabel: true
},
yAxis: {
nameGap: 30,
type: 'value',
splitLine: {
show: false
},
axisLabel: {
show: false
},
splitLine: {
lineStyle: {
color: '#2F314F'
}
},
splitNumber: 4
},
series: [
{
type: 'bar',
symbol: 'circle',
backgroundStyle: {
color: '#6578FF'
},
barWidth: '35%',
data: [120, 200, 150, 80, 70, 110, 130]
}
]
}
return options
}
function getBarReverseOptions(obj) {
var options = {
tooltip: {
trigger: 'axis',
showContent: false,
axisPointer: {
type: 'shadow',
shadowStyle: {
color: 'rgba(210, 210, 210, 0.2)'
}
},
borderWidth: 0,
backgroundColor: 'rgba(68,68,68,0.80)',
confine: true,
textStyle: {
color: '#ffffff',
fontSize: 8
}
},
yAxis: {
type: 'category',
axisLabel: {
color: '#ccc',
fontSize: '0.8em'
},
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLine: {
show: false
},
data: ['一般发展', '一般价值', '一般挽留', '重要挽留', '重要价值', '重要发展', '重要保持', '一般保持']
},
grid: {
left: '15%',
right: '0%',
top: '0%',
bottom: '0%',
containLabel: true
},
xAxis: {
nameGap: 30,
type: 'value',
splitLine: {
show: false
},
axisLabel: {
show: false
},
splitNumber: 4
},
series: [
{
type: 'bar',
symbol: 'circle',
backgroundStyle: {
color: '#6578FF'
},
itemStyle: {
normal: {
label: {
show: true,
position: 'center',
textStyle: {
fontSize: 10,
color: '#fff',
height: 16,
padding: [0, 2, 2, 4],
lineHeight: 16
}
}
}
},
data: [30, 120, 200, 150, 80, 70, 110, 130]
}
]
}
return options
}
function getLineOptions(obj) {
const { dataList, name } = obj
const statDate = dataList.map(item => item.statDate)
const num = dataList.map(item => item.num)
var options = {
tooltip: {
trigger: 'axis',
axisPointer: {
lineStyle: {
type: 'solid'
}
},
padding: 5,
borderWidth: 0.5,
backgroundColor: 'rgba(35, 45, 152, 1)',
borderRadius: 4,
textStyle: {
color: 'rgba(255,255,255,1)',
fontSize: 14
},
formatter: function (item) {
return `${name}:${item[0].value}`
}
},
xAxis: {
type: 'category',
axisLabel: {
color: '#fff',
fontSize: '0.8em'
},
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLine: {
show: false
},
data: statDate
},
grid: {
left: '6%',
right: '6%',
top: '14%',
bottom: '1%',
containLabel: true
},
yAxis: {
nameGap: 30,
type: 'value',
splitLine: {
lineStyle: {
color: '#2F314F'
}
},
axisLabel: {
color: '#fff',
fontSize: '0.8em'
},
splitNumber: 4
},
series: [
{
type: 'line',
symbol: 'circle',
itemStyle: {
color: '#F5AA01'
},
// 平滑曲线
smooth: true,
showSymbol: false,
// 折线背景色
areaStyle: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: 'rgba(254, 84, 0, 0.3)'
},
{
offset: 1,
color: 'rgba(254, 84, 0, 0.01)'
}
]
}
},
data: num
}
]
}
return options
}
function lineAndBarOptions(list) {
const statDate = list.map(item => item.statDate)
const totalNum = list.map(item => item.totalNum)
const increNum = list.map(item => item.increNum)
var options = {
tooltip: {
trigger: 'axis',
axisPointer: {
lineStyle: {
type: 'solid'
}
},
padding: 5,
borderWidth: 0.5,
backgroundColor: 'rgba(35, 45, 152, 1)',
borderRadius: 4,
textStyle: {
color: 'rgba(255,255,255,1)',
fontSize: 14
},
formatter: function (item) {
return `门店数:${item[0].value}<br>新增数:${item[1].value}`
}
},
xAxis: {
type: 'category',
axisLabel: {
color: '#fff',
fontSize: '0.8em'
},
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLine: {
show: false
},
data: statDate
},
grid: {
left: '3%',
right: '6%',
top: '6%',
bottom: '0%',
containLabel: true
},
yAxis: {
nameGap: 30,
type: 'value',
splitLine: {
lineStyle: {
color: '#2F314F'
}
},
axisLabel: {
color: '#fff',
fontSize: '0.8em'
},
splitNumber: 4
},
series: [
{
type: 'bar',
symbol: 'circle',
backgroundStyle: {
color: '#6578FF'
},
barWidth: '30%',
data: increNum
},
{
type: 'line',
symbol: 'circle',
itemStyle: {
color: '#F5AA01'
},
// 平滑曲线
smooth: true,
showSymbol: false,
// 折线背景色
areaStyle: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: 'rgba(254, 84, 0, 0.3)'
},
{
offset: 1,
color: 'rgba(254, 84, 0, 0.01)'
}
]
}
},
data: totalNum
}
]
}
return options
}
export { getBarReverseOptions, getBarOptions, lineAndBarOptions, getLineOptions }