From 27fa305bf0c3a4405366a966c28b4d32203106b8 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期二, 05 十二月 2023 16:32:46 +0800
Subject: [PATCH] 人员生产效率、物料需求统计

---
 src/views/cockpitPage/components/PerSonnelProductivity.vue |  119 +++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 70 insertions(+), 49 deletions(-)

diff --git a/src/views/cockpitPage/components/PerSonnelProductivity.vue b/src/views/cockpitPage/components/PerSonnelProductivity.vue
index db0b593..27a0c8b 100644
--- a/src/views/cockpitPage/components/PerSonnelProductivity.vue
+++ b/src/views/cockpitPage/components/PerSonnelProductivity.vue
@@ -16,35 +16,49 @@
 import ChartTitle from "@/views/cockpitPage/components/ChartTitle.vue";
 //寮曞叆echart
 import * as echarts from "echarts";
+let myChart;
 export default {
   components: {
     ChartTitle,
   },
-  props: {},
+  props: {
+    chartData: {
+      type: Object,
+      require: true,
+      default: () => {
+        return {
+          datax: [],
+          datay: [],
+        };
+      },
+    },
+  },
   data() {
     return {
-      chartData: {
-        datax: ["浜哄憳1", "浜哄憳2", "浜哄憳3", "浜哄憳4", "浜哄憳5", "浜哄憳6"],
-        datay: [120, 200, 150, 380, 470, 150, 230],
-      },
+      startValue: 0,
+      endValue: 5,
+      chartTimer: null,
     };
   },
-  mounted() {
-    this.pieChart("chart", this.chartData);
-    let chartData2 = [
-      { value: 10, name: "涓�绫�" },
-      { value: 20, name: "浜岀被" },
-      { value: 60, name: "涓夌被" },
-      { value: 10, name: "鍥涚被" },
-    ];
-    this.getChartRight("chart2", chartData2);
+  watch: {
+    "chartData.datay"(val) {
+      this.startValue = 0;
+      this.endValue = 5;
+      this.pieChart("chart", this.chartData);
+    },
   },
-  watch: {},
+  mounted() {},
   methods: {
     //鍦ㄨ亴
     pieChart(chartName, data) {
+      let that = this;
+      clearInterval(this.chartTimer);
       let chartDom = this.$refs[chartName];
-      let myChart = echarts.init(chartDom);
+      // let myChart = echarts.init(chartDom);
+      if (myChart != null && myChart != "" && myChart != undefined) {
+        myChart.dispose(); //閿�姣�
+      }
+      myChart = echarts.init(chartDom);
       let option;
       let lineColor = "#35ddc74d";
       if (data) {
@@ -65,24 +79,10 @@
           dataZoom: [
             {
               type: "inside",
-              // show: true, //鏄剧ず婊氬姩鏉�
-              start: 0,
-              end: 100,
               yAxisIndex: 0,
-              minSpan: 20,
-              maxSpan: 100,
-              // handleSize: 8
-            },
-            {
-              //   type: 'slider', //涓や釜涓�涓槸slider锛屼竴涓槸inside锛宻lider鏄鍔犳粴鍔ㄦ潯浠ュ強榧犳爣鎷栧姩婊氬姩鏉″姛鑳斤紝inside鍒欐槸榧犳爣婊氳疆婊氬姩婊氬姩鏉°��
-              type: "inside",
-              // show: true,
-              // realtime : true,
-              yAxisIndex: 0,
-              minSpan: 20,
-              maxSpan: 100,
-              start: 0,
-              end: 100,
+              show: false,
+              startValue: this.startValue, // 浠庡ご寮�濮�
+              endValue: this.endValue, // 涓�娆℃�у睍绀哄嚑涓�
             },
           ],
           legend: {
@@ -124,7 +124,7 @@
           ],
           xAxis: [
             {
-              type: "",
+              type: "value",
               name: "鍗曚綅锛氫欢",
               // min: data.yAxis[0].min?data.yAxis.min:0,
               minInterval: 1, //鍧愭爣杞存槸鏁存暟
@@ -151,7 +151,6 @@
               axisTick: {
                 show: false,
               },
-
               axisLabel: {
                 textStyle: {
                   color: "#00FFFF",
@@ -187,8 +186,21 @@
             },
           ],
         };
+        this.chartTimer = setInterval(function () {
+          if (option.dataZoom[0].endValue == data.datay.length) {
+            option.dataZoom[0].startValue = 0;
+            option.dataZoom[0].endValue = 5;
+          } else {
+            option.dataZoom[0].endValue = option.dataZoom[0].endValue + 1;
+            option.dataZoom[0].startValue = option.dataZoom[0].startValue + 1;
+          }
+          myChart.setOption(option);
+        }, 4000);
 
         option && myChart.setOption(option);
+        window.addEventListener("resize", function () {
+          myChart.resize();
+        });
       } else {
         option = {};
         myChart.setOption(option, true);
@@ -201,7 +213,7 @@
       let option;
       if (data) {
         option = {
-          color: ["#dcb018", "#735b09", "#ebd68e", "#FF3000"],
+          color: ["#dcb018", "#735b09", "#ebd68e", "#c7b36e"],
           tooltip: {
             trigger: "item",
           },
@@ -212,8 +224,8 @@
                 z: 3,
                 style: {
                   image: img,
-                  width: 118,
-                  height: 118,
+                  width: 238,
+                  height: 238,
                 },
                 left: "center",
                 top: "center",
@@ -225,24 +237,29 @@
             {
               name: "Access From",
               type: "pie",
-              // center: ['80%', '46%'],
-              radius: ["52%", "65%"],
-              // minAngle: 20,
-              // startAngle: 60,
+              radius: ["52%", "62%"],
               avoidLabelOverlap: false,
 
               label: {
                 normal: {
                   position: "outer",
-                  paddding: [-100, 70],
-
+                  padding: [0, -62],
                   color: "#01f7fd",
                   fontSize: 12,
-                  borderWidth: 20,
+                  borderWidth: 5,
                   borderRadius: 4,
                   formatter: function (params) {
-                    let str = params.name + params.value + "%";
-                    return str;
+                    return `{a|${params.name}} {b|${params.value + "%"}}`;
+                  },
+                  rich: {
+                    a: {
+                      color: "#00ffff",
+                      fontSize: 14,
+                    },
+                    b: {
+                      color: "#fccd1d",
+                      fontSize: 14,
+                    },
                   },
                 },
               },
@@ -256,12 +273,16 @@
               },
               labelLine: {
                 show: true,
-                length: 20,
-                length2: 10,
+                length: 4,
+                length2: 80,
                 lineStyle: {
                   color: "#dcb018",
                 },
               },
+              labelLayout: {
+                verticalAlign: "bottom",
+                dy: -5,
+              },
               data: data,
             },
           ],

--
Gitblit v1.8.0