From 02d848bf39005e83882a87f8bc322d8499b92fbc Mon Sep 17 00:00:00 2001
From: whychdw <49690745@qq.com>
Date: 星期六, 29 八月 2020 10:05:44 +0800
Subject: [PATCH] 提交修改

---
 src/components/chart/LineChart.vue |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/components/chart/LineChart.vue b/src/components/chart/LineChart.vue
index ffb1995..74aaa70 100644
--- a/src/components/chart/LineChart.vue
+++ b/src/components/chart/LineChart.vue
@@ -48,12 +48,16 @@
                 tooltip: {
                     trigger: 'axis',
                     axisPointer: {            // 鍧愭爣杞存寚绀哄櫒锛屽潗鏍囪酱瑙﹀彂鏈夋晥
-                        type: 'shadow'        // 榛樿涓虹洿绾匡紝鍙�変负锛�'line' | 'shadow'
+                        type: 'line'        // 榛樿涓虹洿绾匡紝鍙�変负锛�'line' | 'shadow'
                     },
+                    appendToBody: true,
                     formatter(params){
                         var res = params[0].name+'<br/>';
-                        res+= params[0].seriesName;
-                        res+=' : '+params[0].data[1]+unit+'</br>';
+                        params.forEach(item=>{
+                            res += item.marker;
+                            res += item.seriesName;
+                            res +=' : '+item.data[1]+unit+'</br>';
+                        });
                         return res;
                     }
                 },
@@ -63,9 +67,11 @@
                     bottom: '2%',
                     containLabel: true
                 },
+                legend: this.getLegend(opt),
                 xAxis: [
                     {
                         type: 'category',
+                        boundaryGap: 0,
                     }
                 ],
                 yAxis: [
@@ -79,11 +85,17 @@
                             if(min == Infinity) {
                                 return 0;
                             }
+                            if(min>0) {
+                                return Math.floor(min*0.9);
+                            }else {
+                                return Math.floor(min*1.01);
+                            }
+                            
                         },
                         max: function(data) {
                             let max = data.max;
                             if(max == -Infinity) {
-                                max = 1;
+                                return 1;
                             }
                             return Math.ceil(max*1.01);
                         }
@@ -91,6 +103,8 @@
                 ],
                 series: this.getSeries(opt),
             };
+            // 娓呯悊鐢诲竷
+            this.$G.chartManage.get(this.id).clear();
             // 璁剧疆閰嶇疆椤�
             this.$G.chartManage.get(this.id).setOption(option);
         },
@@ -114,6 +128,16 @@
             // 杩斿洖鏍囬
             return opt.title;
         },
+        getLegend(opt){
+            // 鏈厤缃甽egend
+            if(!opt || !opt.legend) {
+                return {
+                    show: false,
+                }
+            }
+
+            return opt.legend;
+        },
         getSeries(opt) {    // 璁剧疆series
             // 鏈厤缃畇eries
             if(!opt || !opt.series) {

--
Gitblit v1.9.1