Browse Source

修改所有图表自适应

plg 3 months ago
parent
commit
e498ffbffa

+ 2 - 4
src/components/BingChart.vue

@@ -44,7 +44,6 @@ export default {
     window.addEventListener("resize", this.echartsAllSize);
   },
   destroyed() {
-    console.log("报告页面销毁了");
     window.removeEventListener("resize", this.echartsAllSize);
   },
   methods: {
@@ -144,10 +143,9 @@ export default {
         ],
       };
       pieData && option && myChart.setOption(option);
-      window.onresize = function () {
-        console.log("111111111111饼状图大小变化了吗");
+
         myChart.resize();
-      };
+  
     },
     pieDataHandle(param) {
       this.pieData = [];

+ 0 - 3
src/components/BingChart2.vue

@@ -102,10 +102,7 @@ export default {
         ],
       };
       pieData && option && myChart.setOption(option);
-      window.onresize = function () {
-        // console.log('饼状图大小变化了吗')
         myChart.resize();
-      };
     },
     pieDataHandle(param) {
       this.pieData = [];

+ 18 - 0
src/components/ComparePlanProfession.vue

@@ -458,8 +458,26 @@ export default {
       };
       this.compareHandle();
     });
+
+    //监听页面是否变化
+    window.addEventListener("resize", this.echartsAllSize);
+  },
+  destroyed(){
+    window.removeEventListener("resize", this.echartsAllSize);
   },
   methods: {
+    echartsAllSize(){
+      let flag = false;
+      setTimeout(() => {
+        flag = true;
+        if (flag) {
+          //设置变化的大小
+          console.log("大小变化了---------------------");
+          let myChart = this.$echarts.init(document.getElementById('my_chart'));
+          myChart.resize();
+        }
+      }, 1000);
+    },
     //根据组织改变计划
     subPlanChange1(val) {
       let list = [];

+ 19 - 1
src/components/PerQSChart.vue

@@ -31,7 +31,25 @@ export default {
       this.myZhuEcharts(this.options);
     },
   },
+  mounted() {
+    window.addEventListener("resize", this.echartsAllSize);
+  },
+  destroyed() {
+    window.removeEventListener("resize", this.echartsAllSize);
+  },
   methods: {
+    echartsAllSize() {
+      let flag = false;
+      setTimeout(() => {
+        flag = true;
+        if (flag) {
+          //设置变化的大小
+          console.log("大小变化了---------------------");
+          let myChart = this.$echarts.init(document.getElementById(this.refCurrent));
+          myChart.resize();
+        }
+      }, 1000);
+    },
     myZhuEcharts(data) {
       //修改测试计划
       let myChart = this.$echarts.init(document.getElementById(this.refCurrent));
@@ -99,7 +117,7 @@ export default {
           // },
         },
         yAxis: {
-          max:100,
+          max: 100,
           type: "value",
           name: "分数",
         },

+ 18 - 0
src/components/QSChart.vue

@@ -25,6 +25,12 @@ export default {
   data() {
     return {};
   },
+  mounted() {
+    window.addEventListener("resize", this.echartsAllSize);
+  },
+  destroyed() {
+    window.removeEventListener("resize", this.echartsAllSize);
+  },
   //当前监听到数据发生变化就开始渲染
   watch: {
     options() {
@@ -32,6 +38,18 @@ export default {
     },
   },
   methods: {
+    echartsAllSize() {
+      let flag = false;
+      setTimeout(() => {
+        flag = true;
+        if (flag) {
+          //设置变化的大小
+          console.log("大小变化了---------------------");
+          let myChart = this.$echarts.init(document.getElementById(this.refCurrent));
+          myChart.resize();
+        }
+      }, 1000);
+    },
     myZhuEcharts(data) {
       //修改测试计划
       let myChart = this.$echarts.init(document.getElementById(this.refCurrent));

+ 3 - 0
src/components/ZhuChart.vue

@@ -28,6 +28,9 @@ export default {
   mounted() {
     window.addEventListener("resize", this.echartsAllSize);
   },
+  destroyed(){
+    window.removeEventListener("resize", this.echartsAllSize);
+  },
   //当前监听到数据发生变化就开始渲染
   watch: {
     options() {