From 8d1a8a22ff13bab740ff3c427eb531fd6ce97844 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期二, 05 十二月 2023 15:26:12 +0800
Subject: [PATCH] 机器开机率、工单进度统计、设备负荷比接口联调

---
 src/views/cockpitPage/components/DeviceChart.vue |   77 +++++++++++++++++++++++++-------------
 1 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/src/views/cockpitPage/components/DeviceChart.vue b/src/views/cockpitPage/components/DeviceChart.vue
index ec25403..faf08b0 100644
--- a/src/views/cockpitPage/components/DeviceChart.vue
+++ b/src/views/cockpitPage/components/DeviceChart.vue
@@ -15,40 +15,66 @@
 <script>
 //寮曞叆echart
 import * as echarts from "echarts";
+let myChart;
 export default {
   components: {},
-  props: {},
+  props: {
+    chartData: {
+      type: Object,
+      require: true,
+      default: () => {
+        return {
+          datax: [],
+          datay: [],
+        };
+      },
+    },
+    // xdata: {
+    //   type: Array,
+    //   require: true,
+    // },
+    // ydata: {
+    //   type: Array,
+    //   require: true,
+    // },
+  },
   data() {
     return {
-      chartData: {
-        datax: [
-          "璁惧1",
-          "璁惧2",
-          "璁惧3",
-          "璁惧4",
-          "璁惧5",
-          "璁惧6",
-          "璁惧7",
-          "璁惧8",
-          "璁惧9",
-        ],
-        datay: [10, 20, 15, 38, 47, 50, 20, 33, 25, 48],
-      },
+      // chartData: {
+      //   datax: [],
+      //   datay: [],
+      // },
+      startValue: 0,
+      endValue: 5,
     };
   },
-  mounted() {
-    this.pieChart("chart", this.chartData);
+  watch: {
+    "chartData.datay"(val) {
+      console.log(val, "ddddddddddddddd");
+      this.ydata = val;
+      this.startValue = 0;
+      this.endValue = 5;
+      this.pieChart("chart", this.chartData);
+    },
   },
-  watch: {},
+  mounted() {
+    // this.pieChart("chart", this.chartData);
+  },
   methods: {
     //鍦ㄨ亴
     pieChart(chartName, data) {
       let that = this;
       let chartDom = this.$refs[chartName];
-      let myChart = echarts.init(chartDom);
+      if (myChart != null && myChart != "" && myChart != undefined) {
+        console.log("222222222");
+        myChart.dispose(); //閿�姣�
+        myChart.resize();
+      }
+      console.log(myChart, "ssssssss");
+      myChart = echarts.init(chartDom);
       let option;
       let lineColor = "#35ddc74d";
-      if (data) {
+      if (this.ydata) {
         option = {
           color: ["#00FFFF", "#dcb018"],
           tooltip: {
@@ -68,8 +94,8 @@
               type: "inside",
               yAxisIndex: 0,
               show: false,
-              startValue: 0, // 浠庡ご寮�濮�
-              endValue: 5, // 涓�娆℃�у睍绀哄嚑涓�
+              startValue: that.startValue, // 浠庡ご寮�濮�
+              endValue: that.endValue, // 涓�娆℃�у睍绀哄嚑涓�
             },
           ],
           legend: {
@@ -177,10 +203,9 @@
         };
 
         setInterval(function () {
-          // 姣忔鍚戝乏婊戝姩涓�涓紝鏈�鍚庝竴涓粠澶村紑濮嬨��
-          if (option.dataZoom[0].endValue == that.chartData.datay.length) {
-            option.dataZoom[0].startValue = 0;
-            option.dataZoom[0].endValue = 5;
+          if (option.dataZoom[0].endValue == data.datay.length) {
+            option.dataZoom[0].startValue = that.startValue;
+            option.dataZoom[0].endValue = that.endValue;
           } else {
             option.dataZoom[0].endValue = option.dataZoom[0].endValue + 1;
             option.dataZoom[0].startValue = option.dataZoom[0].startValue + 1;

--
Gitblit v1.8.0