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
| <template>
| <el-card shadow="never" class="aui-card--fill">
| <div class="mod-index-full">
| <el-form :inline="true" :model="dataForm" label-width="100px">
| <el-form-item :label="$t('datePicker.date')">
| <el-date-picker
| v-model="dataForm.dateRange"
| type="datetimerange"
| format="yyyy-MM-dd HH:mm"
| value-format="yyyy-MM-dd HH:mm"
| range-separator="至"
| start-placeholder="开始日期"
| end-placeholder="结束日期">
| </el-date-picker>
| </el-form-item>
| <el-form-item label="产品煤种">
| <dict-select-tag style="width: 100%"
| v-model="dataForm.index"
| placeholder="产品煤种"
| dictCode="cpmz"
| :clearable="false"/>
| </el-form-item>
| <el-form-item>
| <el-button @click="queryChart()">{{ $t('query') }}</el-button>
| </el-form-item>
| </el-form>
| </div>
| <div id="chartLineBox" style="width: 90%;height: 70vh;"> </div>
| </el-card>
| </template>
| <script>
| import DictSelectTag from "@/components/dict/dict-select-tag";
| import BarLine from "@/components/chart/bar-line";
| import {getYMD} from "@/utils/dateUtils";
| import * as echarts from 'echarts'
|
| export default {
| components: {DictSelectTag, BarLine},
| data() {
| return {
| loading: false,
| chartOption: {},
| dataForm: {
| groupType: 'day',
| dateRange: [],
| index: ''
| }
| }
| },
| mounted() {
| this.chartLine = echarts.init(document.getElementById('chartLineBox'));
|
| // 指定图表的配置项和数据
| var option = {
| tooltip: { //设置tip提示
| trigger: 'axis'
| },
| color: ['#869ad7'], //设置区分(每条线是什么颜色,和 legend 一一对应)
| xAxis: { //设置x轴
| boundaryGap: false,
| type: 'category',
| boundaryGap: false, //坐标轴两边不留白
| data: ['2023-5-31', '2023-6-1', '2023-6-2', '2023-6-3', '2023-6-4', '2023-6-5', '2023-6-6','2023-6-7',],
| name: '日期', //X轴 name
| nameTextStyle: { //坐标轴名称的文字样式
| color: 'black',
| fontSize: 16,
| padding: [0, 0, 0, 20]
| },
| axisLine: { //坐标轴轴线相关设置。
| lineStyle: {
| color: 'black',
| }
| }
| },
| yAxis: {
| nameTextStyle: {
| color: 'black',
| fontSize: 16,
| padding: [0, 0, 10, 0]
| },
| axisLine: {
| lineStyle: {
| color: 'black',
| }
| },
| type: 'value'
| },
| series: [
| {
| areaStyle: {},
| name: '产量',
| data: [234,200,127,145,219,150,300,109],
| type: 'line',
| lineStyle: {
| normal: {
| color: '#869ad7',
| }
| },
| }
| ]
| };
|
| // 使用刚指定的配置项和数据显示图表。
| this.chartLine.setOption(option);
|
| },
| methods: {
| init() {
| this.dataForm.dateRange = []
| this.dataForm.dateRange.push(getYMD(new Date().getTime() - 3600 * 1000 * 24 * 30) + ' 00:00')
| this.dataForm.dateRange.push(getYMD(new Date()) + ' 23:59')
| },
|
| queryChart() {
| let params = {
| groupType: this.dataForm.groupType,
| startDate: this.dataForm.dateRange[0] + ':00',
| endDate: this.dataForm.dateRange[1] + ':59',
| index: this.dataForm.index
| }
| this.loading = true
| this.$http.post(`/iailab-iems-coal-proddisp/analysis/index/chart`, params).then(({data: res}) => {
| this.loading = false
| if (res.code !== 0) {
| return this.$message.error(res.msg)
| }
| let series = []
| if (res.data.series) {
| res.data.series.forEach(function (item) {
| series.push(
| {
| name: item.name,
| data: item.data,
| type: 'line',
| smooth: false
| }
| )
| })
| }
|
| this.chartOption = {
| grid: {
| top: '8%',
| right: '10%',
| bottom: '12%',
| left: '10%'
| },
| legend: {
| type: 'scroll',
| orient: 'vertical',
| right: 5,
| top: 20,
| bottom: 20,
| data: res.data.legend
| },
| toolbox: {
| show: true,
| top: 0,
| right: '10%',
| feature: {
| dataView: {readOnly: false},
| magicType: {type: ['line', 'bar']},
| saveAsImage: {}
| }
| },
| xAxis: {
| type: 'category',
| data: res.data.categories
| },
| yAxis: {
| type: 'value',
| name: res.data.valueName,
| nameTextStyle: {
| fontWeight: 'bold'
| },
| axisLine: {
| show: true
| }
| },
| series: series
| }
|
| }).catch(() => {
| this.loading = false
| })
| }
| }
| }
| </script>
|
|