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
| import echarts from 'echarts'
| import dayjs from 'dayjs'
|
| function drawSafetyLine () {
| const myChart = echarts.init(document.getElementById('safetyIndex'))
| const yyyy = dayjs().format('YYYY') + '-'
| const resDate = ['07-10', '07-11', '07-12', '07-13', '07-14', '07-15', '07-16']
| const resValue = [35, 20, 10, 20, 40, 30, 10]
| const safetyStandardValue = 20
| myChart.setOption({
| tooltip: {
| trigger: 'axis',
| formatter: '<span style="text-align: center;display:block; color: #33FF90">' + yyyy + '{b0}</span>' +
| '<span style="color: #33FF90">{a0}:{c0}</span><br/>' +
| '<span style="color: #33FF90">安全标准指数:' + safetyStandardValue + '</span>', // 自定义tip格式
| backgroundColor: 'rgba(73,177,231, 0.1)',
| axisPointer: {
| lineStyle: {
| color: 'rgba(73,177,231, 0.5)',
| type: 'dashed'
| }
| }
| },
| grid: {
| left: '4%',
| right: '10%',
| bottom: '3%',
| containLabel: true
| },
| xAxis: {
| type: 'category',
| boundaryGap: false,
| data: resDate,
| axisLine: {
| show: false,
| lineStyle: {
| color: '#33FFF8'
| }
| },
| axisTick: { // x轴刻度线
| show: false
| }
| },
| yAxis: {
| type: 'value',
| splitLine: {
| lineStyle: {
| type: 'dotted', // 设置网格线类型 dotted:虚线 solid:实线
| color: 'rgb(73,177,231, 0.3)'
| },
| show: true
| },
| axisLine: {
| show: false,
| lineStyle: {
| color: '#33FFF8'
| }
| },
| axisTick: { // y轴刻度线
| show: false
| },
| nameTextStyle: {
| lineHeight: 20
| }
| },
| series: [
| {
| name: '安全指数',
| type: 'line',
| data: resValue,
| itemStyle: {
| normal: {
| lineStyle: {
| color: 'rgb(233,209,74)',
| width: 2 // 设置线条粗细
| }
| }
| },
| markLine: {
| symbol: 'none', // 去掉标准线箭头
| data: [
| {
| label: {
| normal: {
| position: 'end',
| formatter: ''
| }
| },
| name: '标准值',
| yAxis: 20,
| lineStyle: {
| type: 'solid',
| color: '#33FFF8',
| width: 1
| }
| }
| ]
| }
| }
| ]
| })
| window.addEventListener('resize', () => {
| myChart.resize()
| })
| }
|
| export default {
| drawSafetyLine
| }
|
|