From 1dbdda3517a01851d8d9894b22e61aa4462b541c Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期四, 07 十二月 2023 19:16:36 +0800
Subject: [PATCH] tooltip值优化

---
 src/views/cockpitPage/components/PerSonnelProductivity.vue |   68 +++++++++++++++++++++++++++-------
 1 files changed, 54 insertions(+), 14 deletions(-)

diff --git a/src/views/cockpitPage/components/PerSonnelProductivity.vue b/src/views/cockpitPage/components/PerSonnelProductivity.vue
index 904cdf8..4f11181 100644
--- a/src/views/cockpitPage/components/PerSonnelProductivity.vue
+++ b/src/views/cockpitPage/components/PerSonnelProductivity.vue
@@ -17,6 +17,7 @@
 //寮曞叆echart
 import * as echarts from "echarts";
 let myChart;
+let myRightChart;
 export default {
   components: {
     ChartTitle,
@@ -69,6 +70,9 @@
             axisPointer: {
               type: "none",
             },
+            valueFormatter: function (value) {
+              return value + "%";
+            },
           },
           grid: {
             right: "80px",
@@ -83,6 +87,9 @@
               show: false,
               startValue: this.startValue, // 浠庡ご寮�濮�
               endValue: this.endValue, // 涓�娆℃�у睍绀哄嚑涓�
+              zoomOnMouseWheel: false,
+              moveOnMouseWheel: true,
+              moveOnMouseMove: true,
             },
           ],
           legend: {
@@ -108,7 +115,7 @@
                 // rotate:45,
                 margin: 10,
                 show: true,
-                fontSize:12,
+                fontSize: 12,
                 textStyle: {
                   color: function (params, index) {
                     let colorList = ["#dcb018", "#00FFFF"];
@@ -132,7 +139,7 @@
           xAxis: [
             {
               type: "value",
-              name: "鍗曚綅锛氫欢",
+              // name: "鍗曚綅锛氫欢",
               // min: data.yAxis[0].min?data.yAxis.min:0,
               minInterval: 1, //鍧愭爣杞存槸鏁存暟
               max: Math.ceil(eval(`Math.max(${data.datay})`) / 5) * 5, //鏁版嵁鏈�澶у�煎姞3
@@ -162,6 +169,9 @@
                 textStyle: {
                   color: "#00FFFF",
                 },
+                formatter: function (value) {
+                  return `${value}%`;
+                },
               },
             },
           ],
@@ -173,7 +183,21 @@
               label: {
                 show: true,
                 position: "right",
-                color: "#00FFFF",
+                formatter: function (params) {
+                  if (params.dataIndex % 2 == 0) {
+                    return `{a|${params.value}%}`;
+                  } else {
+                    return `{b|${params.value}%}`;
+                  }
+                },
+                rich: {
+                  a: {
+                    color: "#00FFFF",
+                  },
+                  b: {
+                    color: "#dcb018",
+                  },
+                },
               },
               itemStyle: {
                 normal: {
@@ -215,24 +239,36 @@
     },
     getChartRight(chartName, data) {
       let chartDom = this.$refs[chartName];
-      let myChart = echarts.init(chartDom);
+      if (
+        myRightChart != null &&
+        myRightChart != "" &&
+        myRightChart != undefined
+      ) {
+        myRightChart.dispose(); //閿�姣�
+      }
+      myRightChart = echarts.init(chartDom);
       let img = "/cockpitPage/dotted-circle.png";
+      let height = myRightChart.getHeight() / 1;
+      let width = height + 5;
       let option;
       if (data) {
         option = {
           color: ["#dcb018", "#735b09", "#ebd68e", "#c7b36e"],
           tooltip: {
             trigger: "item",
+            valueFormatter: function (value) {
+              return value + "%";
+            },
           },
           graphic: {
             elements: [
               {
                 type: "image",
-                z: 3,
+                // z: 3,
                 style: {
                   image: img,
-                  width: 240,
-                  height: 240,
+                  width: width,
+                  height: height,
                 },
                 left: "center",
                 top: "center",
@@ -256,7 +292,11 @@
                   borderWidth: 5,
                   borderRadius: 4,
                   formatter: function (params) {
-                    return `{a|${params.name}} {b|${params.value + "%"}}`;
+                    let label =
+                      params.name.length > 4
+                        ? `${params.name.slice(0, 3)}...`
+                        : params.name;
+                    return `{a|${label}} {b|${params.value + "%"}}`;
                   },
                   rich: {
                     a: {
@@ -281,7 +321,7 @@
               labelLine: {
                 show: true,
                 length: 4,
-                length2: 80,
+                length2: 70,
                 lineStyle: {
                   color: "#dcb018",
                 },
@@ -295,10 +335,10 @@
           ],
         };
 
-        option && myChart.setOption(option);
+        option && myRightChart.setOption(option);
       } else {
         option = {};
-        myChart.setOption(option, true);
+        myRightChart.setOption(option, true);
       }
     },
   },
@@ -308,7 +348,7 @@
 <style scoped lang="scss">
 .bar-chart {
   width: 100%;
-  height: calc(100% - 20px);
+  height: calc(100% - 10px);
   padding: 20px 0 0;
 
   .bar-contents {
@@ -317,7 +357,7 @@
 
     .chart-left {
       width: calc(60% - 20px);
-      height: 100%;
+      height: calc(100% - 20px);
       margin-right: 20px;
       float: left;
       border: 1px solid #00ffff;
@@ -327,7 +367,7 @@
     .chart-right {
       width: 40%;
       float: left;
-      height: 100%;
+      height: calc(100% - 20px);
       position: relative;
       .chart-bg {
         width: 100%;

--
Gitblit v1.8.0