maxiaoxiao vor 1 Jahr
Ursprung
Commit
0ecf11b5b3
1 geänderte Dateien mit 31 neuen und 6 gelöschten Zeilen
  1. 31 6
      src/components/echartsTemplate/3dPie.vue

+ 31 - 6
src/components/echartsTemplate/3dPie.vue

@@ -14,17 +14,28 @@ let option = {
     itemHeight: 12, // 设置高度
     data: ["征收", "收购", "回收"],
     bottom: "40%",
-    right: "40%",
+    right: "10%",
 
     itemGap: 10,
     textStyle: {
       color: "#fff",
       fontSize: 14,
     },
-    formatter: function (name) {
-      console.log(name);
-
-      return name;
+    textStyle: {
+      rich: {
+        name: {
+          color: "#BCD3E5",
+          fontSize: 14,
+        },
+        value: {
+          color: "#64DAFF",
+          fontSize: 14,
+        },
+        unit: {
+          color: "#BCD3E5",
+          fontSize: 14,
+        },
+      },
     },
   },
   animation: true,
@@ -85,10 +96,24 @@ export default {
         // var dom = document.getElementById("sankey_echart");
         this.myChart = echarts.init(this.$refs.echart);
       }
-      
       this.initEchartXzqh(data);
     },
     initEchartXzqh(optionsData) {
+      option.legend.formatter = function (name) {
+        const sItem = optionsData.find((item) =>
+          `${item.name}`.includes(`${name}`)
+        );
+        if (sItem) {
+          console.log(sItem, "sItem");
+          
+          return `{name|${name}}  {value|${sItem.value}}  {unit|km²} `;
+          // return name + 'sItem.value';
+        } else {
+          console.log(name);
+
+          return name;
+        }
+      };
       const series = this.getPie3D(optionsData, 0.6);
       option.series = series;