chartConfig.js
1.93 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
import dayjs from 'dayjs'
export const tooltipConfig = {
trigger: 'axis',
borderColor: '#fff',
backgroundColor: '#fff',
padding: 8,
textStyle: {
color: '#656565',
fontSize: 12
},
extraCssText: 'box-shadow: 0 2px 8px 0 #00000026;',
// position: function (point, params, dom, rect, size) { // 解决tooltip在最右侧时部分被遮挡
// let obj = {};
// if (point[0] > size.viewSize[0] / 2) { // 鼠标位置位于echarts容器的一半位置右侧时,提示框显示在左侧
// obj['left'] = point[0] - size.contentSize[0] - 20;
// } else {
// obj['right'] = size.viewSize[0] - size.contentSize[0] * 2;
// }
// if (point[1] > size.viewSize[1] / 2) { // 鼠标位置位于echarts容器的一半位置下侧时,提示框显示在上侧
// obj['top'] = point[1] - size.contentSize[1] - 20;
// } else {
// obj['bottom'] = size.viewSize[1] - size.contentSize[1] * 2;
// }
// return obj;
// }
}
export const xAxisConfig = (params) => {
let { allYear, dateType } = params.searchTime,
xaxis = {
type: 'category',
boundaryGap: false,
splitLine: {
show: false
},
axisTick: {
alignWithLabel: true
},
axisLabel: {
showMaxLabel: true,
formatter: function (value, index) {
let str = ''
str = allYear ? dayjs(value).format('MM月') : dayjs(value).format('MM/DD')
if (dateType == 1) str = value
return str
}
}
}
if (allYear) xaxis.splitNumber = 11
return xaxis
}
export const dataZoomSliderConfig = (params, timeList) => {
return {
type: 'slider',
left: 100,
right: 100,
labelFormatter (value) {
let { allYear, dateType } = params.searchTime,
str = allYear ? dayjs(timeList[value]).format('YYYY年MM月') : dayjs(timeList[value]).format('YYYY-MM-DD')
if(dateType == 1) str = timeList[value]
return str
}
}
}