liyongli 3 년 전
부모
커밋
7704b61269
2개의 변경된 파일43개의 추가작업 그리고 13개의 파일을 삭제
  1. 42 12
      src/components/maincomponents.vue
  2. 1 1
      src/view/main.vue

+ 42 - 12
src/components/maincomponents.vue

@@ -197,17 +197,14 @@ export default {
     hd() {
       this.init();
     },
-    topic() {
-      this.init();
-    },
   },
   mounted() {
     this.height = (this.$refs.main.offsetWidth / 24) * 6.9;
-    this.init();
   },
   computed: {},
   methods: {
     init() {
+      console.log("--");
       linechart && linechart.destroy();
       barchart && barchart.destroy();
       piechart && piechart.destroy();
@@ -232,10 +229,26 @@ export default {
           }
         }
         this.plays = pli;
-        this.pie1(pli);
+
+        if (!pli || !pli.length) {
+          document.getElementById("piechart").style.display = "none";
+        } else {
+          document.getElementById("piechart").style.display = "block";
+        }
+        this.$nextTick(() => {
+          this.pie1(pli);
+        });
       });
       qushiData(this.topic).then(r => {
-        this.line1(r);
+        let li = r || [];
+        if (!li || !li.length) {
+          document.getElementById("container").style.display = "none";
+        } else {
+          document.getElementById("container").style.display = "block";
+        }
+        this.$nextTick(() => {
+          this.line1(li);
+        });
       });
       this.bmGet();
       pingtaiData({
@@ -307,7 +320,15 @@ export default {
         depRange: this.type,
         title: this.topic,
       }).then(r => {
-        this.bar1((r || []).reverse());
+        let li = (r || []).reverse();
+        if (!li || !li.length) {
+          document.getElementById("barChart").style.display = "none";
+        } else {
+          document.getElementById("barChart").style.display = "block";
+        }
+        this.$nextTick(() => {
+          this.bar1(li);
+        });
       });
     },
     numform(text) {
@@ -319,7 +340,10 @@ export default {
       return num;
     },
     line1(li) {
-      if (linechart) linechart.destroy();
+      if (linechart) {
+        linechart.destroy();
+        linechart = null;
+      }
       const that = this;
       // 传播量趋势
       linechart = new F2.Chart({
@@ -355,7 +379,7 @@ export default {
         },
       });
       linechart.tooltip({
-        triggerOn: ["touchstart", "touchmove"],
+        triggerOn: ["click"],
         onShow: function onShow(ev) {
           const items = ev.items;
           items[0].name = items[0].title;
@@ -381,7 +405,10 @@ export default {
       linechart.render();
     },
     bar1(li) {
-      if (barchart) barchart.destroy();
+      if (barchart) {
+        barchart.destroy();
+        barchart = null;
+      }
       const that = this;
       barchart = new F2.Chart({
         id: "barChart",
@@ -435,7 +462,10 @@ export default {
       });
     },
     pie1(li) {
-      if (piechart) piechart.destroy();
+      if (piechart) {
+        piechart.destroy();
+        piechart = null;
+      }
       const that = this;
       piechart = new F2.Chart({
         id: "piechart",
@@ -457,7 +487,7 @@ export default {
       });
       // 添加饼图文本
       piechart.pieLabel({
-        anchorOffset: 0,
+        anchorOffset: -10,
         label1: function label1(data, color) {
           return {
             text: data.p,

+ 1 - 1
src/view/main.vue

@@ -15,7 +15,7 @@
       <div style="float: right;height:23px;line-height:23px;padding-right: 5px">{{username}}</div>
     </div>
     <div class="mainRight">
-      <com-main v-if="hd" :hd="hd" :topic="hdName"></com-main>
+      <com-main :hd="hd" :topic="hdName"></com-main>
     </div>
     <div class="aside">
       <div class="son hd">