liqk il y a 3 ans
Parent
commit
e52d85ba54

+ 11 - 5
TEAMModelOS/ClientApp/src/view/learnactivity/echarts/KngPoint.vue

@@ -1,13 +1,13 @@
 <template>
     <div class="recognize-perform-chart">
-        <div :id="'knowledge'+id" style="width: 306px; height: 300px;margin:auto" v-if="knowledge.kn.length"></div>
-        <div v-else class="no-kn-point">
+        <div v-if="!knowledge.kn || !knowledge.kn.length" class="no-kn-point">
             <p class="chart-title">{{$t('studentWeb.exam.chart.keyPointPerformance')}}</p>
             <img src="@/assets/image/none.png" alt="" class="tips-img">
             <p class="chart-text">
                 {{$t('learnActivity.simple.noKn')}}
             </p>
         </div>
+        <div :id="'knowledge'+id" style="width: 306px; height: 300px;margin:auto" v-else></div>
     </div>
 </template>
 
@@ -30,6 +30,7 @@ export default {
             id: '',
             categories: [],
             akps: [], //个人
+            myChart: undefined
         }
     },
     created() {
@@ -44,7 +45,7 @@ export default {
                     name: item
                 })
             })
-            let myChart = this.$echarts.init(document.getElementById("knowledge" + this.id), 'macarons')
+            if (!this.myChart) this.myChart = this.$echarts.init(document.getElementById("knowledge" + this.id), 'macarons')
             let option = {
                 title: {
                     text: this.$t('studentWeb.exam.chart.keyPointPerformance'),
@@ -76,7 +77,7 @@ export default {
                     }
                 ],
             }
-            myChart.setOption(option)
+            this.myChart.setOption(option)
         },
         getFiled() {
             let akps = []
@@ -103,6 +104,11 @@ export default {
                         this.getFiled()
                         this.setMap()
                     })
+                } else {
+                    if (this.myChart) {
+                        this.myChart.dispose()
+                        this.myChart = undefined
+                    }
                 }
             }
         }
@@ -125,7 +131,7 @@ export default {
         width: 120px;
         margin-top: 30px;
     }
-    .chart-text{
+    .chart-text {
         font-size: 12px;
         color: #808695;
     }