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
| <template>
| <div>
| <div
| class="box-container"
| id="echarts5"
| style="width: 100%; height: 230px"
| ></div>
| </div>
| </template>
|
| <script>
| import * as echarts from "echarts";
| import { zhu } from "./img/t.js";
|
| export default {
| props: {
| produceCompletionData: {
| type: Array,
| default: () => [],
| },
| },
| data() {
| return {
| option: {},
| myChart: {},
| timechartes: null,
| myChart2: null,
| textureImg: null,
| // img,
| };
| },
| watch: {
| produceCompletionData(val) {
| let xData = [],
| yData1 = [],
| yData2 = [],
| yData3 = [];
| val.forEach((item) => {
| console.log("ceshi", item.completionNum);
| xData.push(item.month);
| yData1.push({
| // value: item.completionNum,
| value: 100,
| symbolRepeat: false,
| }); //实际
| // yData1.push(item.completionNum); //实际
| var num = 0; //已完成数 / 计划完成数
| if (item.completionNum > 0) {
| if (item.planCompletionNum > item.completionNum) {
| // 5/10
| num = item.completionNum / item.planCompletionNum;
| } else if (item.planCompletionNum <= 0) {
| // 10/0
| num = 100;
| } else if (item.completionNum >= item.planCompletionNum) {
| // 10/5
| num = 100;
| }
| }
| yData2.push(num.toFixed(2)); //planCompletionRate
| // yData2.push(item.planCompletionRate); //planCompletionRate
| // yData3.push(item.planCompletionNum); //计划
| });
| this.$set(this.option.xAxis, "data", xData);
| this.$set(this.option.series[0], "data", yData1);
| this.$set(this.option.series[1], "data", yData2);
| this.$nextTick(() => {
| this.myChart.setOption(this.option);
| });
| },
| },
| mounted() {
| this.myChart = this.$echarts.init(document.getElementById("echarts5"));
| this.option = {
| tooltip: {
| trigger: "axis",
| formatter:
| "{b0}月<br />" +
| // '<a style="display:inline-block;width:10px;height:10px;background:linear-gradient(to bottom,#13e5f2,#01afba);border-radius:50%"></a> {a0}: {c0}<br />' +
| // '<a style="display:inline-block;width:10px;height:10px;background:linear-gradient(to bottom,#ffc107,#fd7e14);border-radius:50%"></a> {a2}: {c2}<br />' +
| '<a style="display:inline-block;width:10px;height:10px;background:linear-gradient(to bottom,#fff,#eee);border-radius:50%"></a> {a1}: {c1}%<br />', // 添加生产计划数提示
| backgroundColor: "rgba(0,0,0,0.7)",
| textStyle: {
| color: "#ffffff",
| },
| },
| grid: {
| top: "15%",
| bottom: "8%",
| left: "18%",
| right: "18%",
| },
| xAxis: {
| data: [],
| type: "category",
| axisLabel: {
| color: "#326e92",
| interval: 0,
| fontSize: 13,
| // formatter: '{value}月'
| },
| axisTick: {
| show: false,
| },
| axisLine: {
| lineStyle: {
| color: "#326e92",
| },
| },
| },
| yAxis: [
| {
| type: "value",
| position: "left",
| axisLine: {
| show: false,
| lineStyle: {
| color: "#326e92",
| },
| },
| axisLabel: {
| show: true,
| margin: 5,
| color: "#326e92",
| formatter: "{value}%",
| },
| alignTicks: false,
| nameTextStyle: {
| color: "#fff",
| },
| splitLine: {
| lineStyle: {
| color: "#326e92",
| },
| },
| },
| {
| show: true,
| type: "value",
| position: "right",
| // name: "持续时长",
| axisLine: {
| show: false,
| lineStyle: {
| color: "#326e92",
| },
| },
| axisLabel: {
| show: true,
| color: "#326e92",
| formatter: "{value}%",
| },
| nameTextStyle: {
| color: "#326e92",
| },
| splitLine: {
| lineStyle: {
| color: "#326e92",
| },
| },
| },
| ],
| series: [
| {
| name: "生产完成数",
| type: "pictorialBar",
| // type: "bar",
| symbol: "image://" + zhu,
| data: [],
| // yAxisIndex: 0,
| // color: {
| // type: "linear",
| // x: 0,
| // y: 0,
| // x2: 0,
| // y2: 1,
| // colorStops: [
| // {
| // offset: 0,
| // color: "#13e5f2", // 0% 处的颜色
| // },
| // {
| // offset: 1,
| // color: "#01afba", // 100% 处的颜色
| // },
| // ],
| // },
| },
| {
| name: "生产完成率",
| type: "line",
| data: [],
| z: 5,
| showSymbol: true,
| yAxisIndex: 1,
| smooth: true, // 使折线图平滑
| color: "#ff9600",
| lineStyle: {
| width: 1,
| },
| },
| // {
| // name: "生产计划数", // 添加生产计划数
| // type: "line",
| // data: [], // 根据需要填充此数组
| // showSymbol: true,
| // smooth: true, // 使折线图平滑
| // yAxisIndex: 0, // 与相应的 y 轴关联
| // color: "rgba(255,255,255,0.85)", // 自定义颜色
| // lineStyle: {
| // width: 1,
| // },
| // },
| ],
| // animation: true,
| // dataZoom: [
| // {
| // xAxisIndex: 0, //这里是从X轴的0刻度开始
| // show: false, //是否显示滑动条,不影响使用
| // type: "inside", // 这个 dataZoom 组件是 slider 型 dataZoom 组件
| // startValue: 0, // 从头开始。
| // endValue: 5, // 一次性展示几个。
| // },
| // ],
| };
| this.myChart.setOption(this.option);
| const that = this;
| window.addEventListener("resize", () => {
| that.myChart.resize();
| });
| // this.barChartScrolling();
| // this.defineEvent()
| // window.addEventListener("resize", ()=> {
| // this.myChart.resize();
| // });
| // this.init()
| },
| methods: {
| // 水平滚动
| barChartScrolling() {
| const x = this.option.xAxis.data;
| const y1 = this.option.series[0].data;
| const y2 = this.option.series[1].data;
| if (x.length > 0 && y1.length > 0 && y2.length > 0) {
| this.timechartes = setInterval(this.handle, 1500);
| }
| },
|
| handle() {
| const option = this.option;
| const x = this.option.xAxis.data;
| // 每次向后滚动一个,最后一个从头开始。
| if (option.dataZoom[0].endValue == x.length) {
| this.$set(option.dataZoom[0], "endValue", 5);
| this.$set(option.dataZoom[0], "startValue", 0);
| } else {
| this.$set(
| option.dataZoom[0],
| "endValue",
| option.dataZoom[0].endValue + 1
| );
| this.$set(
| option.dataZoom[0],
| "startValue",
| option.dataZoom[0].startValue + 1
| );
| }
| this.myChart.setOption(option);
| },
|
| // 鼠标触摸轮播悬停事件
| defineEvent() {
| // 鼠标移出轮播继续
| this.myChart.on("mouseout", () => {
| if (this.timechartes) clearInterval(this.timechartes);
| this.timechartes = setInterval(this.handle, 1500);
| });
|
| // 鼠标进入轮播悬停
| this.myChart.on("mouseover", () => {
| clearInterval(this.timechartes);
| });
| },
|
| init() {
| var chartDom = document.getElementById("main");
| var myChart = echarts.init(chartDom);
| var option;
| var rocket = "";
|
| option = {
| legend: {
| data: ["tu1", "barbg1"],
| },
| xAxis: {
| data: ["a", "b", "c", "d"],
| },
| yAxis: {
| show: true,
| },
| series: [
| {
| type: "pictorialBar",
| name: "tu1",
| symbol: "image://" + zhu,
| data: [
| {
| value: 60,
| symbolRepeat: false,
| },
| {
| value: 60,
| symbolRepeat: false,
| },
| {
| value: 60,
| symbolRepeat: false,
| },
| {
| value: 60,
| symbolRepeat: false,
| },
| ],
| },
| ],
| };
| myChart.setOption(option);
| },
| },
| };
| </script>
|
| <style></style>
|
|