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
| <template>
| <flex-layout>
| <div class="full-height layout-box layout-box-top">
| <flex-box title="组端电压">
| <e-chart-wrapper ref="groupVol"></e-chart-wrapper>
| </flex-box>
| </div>
| </flex-layout>
| </template>
|
| <script>
| import EChartWrapper from "@/components/chart/EChartWrapper";
| import FlexBox from "@/components/FlexBox";
| import getYMin from "@/components/chart/js/getYMin";
| import getYMax from "@/components/chart/js/getYMax";
| import {formatSeconds} from "@/assets/js/tools";
| import echarts from 'echarts';
| import getSpecialPointIndex from "@/assets/js/tools/getSpecialPointIndex";
| export default {
| name: "lineMarkPoint",
| chartOpts(option) {
| let opt = option?option:{};
| let unit = opt.unit?option.unit:"";
| return {
| animation: false,
| tooltip: {
| trigger: 'axis',
| axisPointer: { // 坐标轴指示器,坐标轴触发有效
| type: 'line' // 默认为直线,可选为:'line' | 'shadow'
| },
| appendToBody: true,
| },
| grid: {
| top: '32px',
| left: '1%',
| right: '1%',
| bottom: '18px',
| containLabel: true
| },
| xAxis: [
| {
| type: 'category',
| }
| ],
| yAxis: [
| {
| type: 'value',
| name: unit?'Y('+unit+')':'Y',
| min: getYMin,
| max: getYMax,
| },
| ],
| series: [],
| }
| },
| components: {
| FlexBox,
| EChartWrapper
| },
| data() {
| return {}
| },
| methods: {
| resize() {
| this.$nextTick(()=>{
| this.$refs.groupVol.resize();
| });
| },
| setOption() {
| this.$refs.groupVol.setOption(this.$options.chartOpts({}));
| },
| setData() {
| let start = 53.5;
| let data = [];
| for(let i=0; i<10; i++) {
| start = start-0.3;
| data.push(start)
| }
| for(let i=0; i<20; i++) {
| start = start+0.4;
| data.push(start)
| }
| for(let i=0; i<100; i++) {
| start = start-0.01;
| data.push(start)
| }
| for(let i=0; i<100; i++) {
| start = start-0.4;
| data.push(start)
| }
| data = data.map(item=>{
| return item.toHold(2);
| });
|
| let specialPoint = getSpecialPointIndex(data);
| let markLine = null;
| if(specialPoint.code) {
| markLine ={
| data: [
| {
| xAxis: formatSeconds(specialPoint.min)
| },
| {
| xAxis: formatSeconds(specialPoint.max)
| }
| ]
| }
| }
|
| let volList = data.map((item,key)=>{
| return [formatSeconds(key), item.toFixed(2)];
| });
| let groupVolOpts = this.$options.chartOpts({
| unit: "V"
| });
| groupVolOpts.series = [
| {
| type: 'line',
| name: "组端电压",
| smooth: false,
| symbolSize: 0,
| sampling: 'average',
| data: volList,
| markLine: markLine,
| }
| ];
| this.$refs.groupVol.setOption(groupVolOpts);
| },
| },
| mounted() {
| this.setOption();
| setTimeout(()=>{
| this.setData();
| }, 2000);
|
| window.addEventListener('resize', this.resize);
| },
| destroyed() {
| window.removeEventListener('resize', this.resize)
| }
| }
| </script>
|
| <style scoped>
| .layout-box {
| box-sizing: border-box;
| padding: 8px;
| }
| </style>
|
|