Prechádzať zdrojové kódy

任务详情的折线图优化

zhangliang2 3 rokov pred
rodič
commit
fec256f51e

+ 6 - 0
src/components/echarts/lineChartTaskInfo.vue

@@ -54,11 +54,17 @@ export default {
                     //提示框,可以在全局也可以在
                     trigger: "item", //提示框的样式
                     formatter: "{b}: {c}",
+                    // formatter: function (params) {
+                    //     if (params.value == 0) return params.name + " : 0";
+                    //     //格式化函数
+                    //     return params.name + " : " + params.value.toFixed(4);
+                    // },
                     color: "#000", //提示框的背景色
                     textStyle: {
                         //提示的字体样式
                         color: "#ffffff",
                     },
+                    confine: true,
                 },
                 xAxis: {
                     name: "t(s)",

+ 16 - 9
src/views/workManagement/taskInfo.vue

@@ -57,31 +57,31 @@
             <div class="contentBox">
                 <div class="info">
                     <span>里程(千米):</span>
-                    <b>{{ info.mileage }}</b>
+                    <b>{{ getNumber(info.mileage) }}</b>
                 </div>
                 <div class="info">
                     <span>平均速度(千米/小时):</span>
-                    <b>{{ info.averageVelocity }}</b>
+                    <b>{{ getNumber(info.averageVelocity) }}</b>
                 </div>
                 <div class="info">
                     <span>最大速度(千米/小时):</span>
-                    <b>{{ info.maximunSpeed }}</b>
+                    <b>{{ getNumber(info.maximunSpeed) }}</b>
                 </div>
                 <div class="info">
                     <span>最小速度(千米/小时):</span>
-                    <b>{{ info.minimunVelocity }}</b>
+                    <b>{{ getNumber(info.minimunVelocity) }}</b>
                 </div>
                 <div class="info">
                     <span>最大加速度(千米/小时):</span>
-                    <b>{{ info.maximumAcceleration }}</b>
+                    <b>{{ getNumber(info.maximumAcceleration) }}</b>
                 </div>
                 <div class="info">
                     <span>最大减速度(千米/小时):</span>
-                    <b>{{ info.maximumDeceleration }}</b>
+                    <b>{{ getNumber(info.maximumDeceleration) }}</b>
                 </div>
                 <div class="info">
                     <span>最大摆角速度(弧度/秒):</span>
-                    <b>{{ info.maximumSwingSpeed }}</b>
+                    <b>{{ getNumber(info.maximumSwingSpeed) }}</b>
                 </div>
             </div>
         </div>
@@ -279,7 +279,13 @@ export default {
 
     computed: {},
 
-    methods: {},
+    methods: {
+        getNumber(val) {
+            if (isNaN(val)) return "";
+            if (val == 0) return 0;
+            return Number(val).toFixed(4);
+        },
+    },
 
     mounted() {
         let taskId = this.$route.query.taskId;
@@ -300,7 +306,6 @@ export default {
                     this.info = res.info;
                     this.xList = res.info.curveData.time;
 
-
                     this.yListA = res.info.curveData.acceleration;
                     this.yListB = res.info.curveData.lane_offset;
                     this.yListC = res.info.curveData.brake;
@@ -456,7 +461,9 @@ export default {
         .chart {
             width: 33%;
             height: calc(25vh);
+            margin-right: 3px;
             margin-bottom: 60px;
+            overflow: hidden;
 
             .title {
                 text-align: center;