liyongli 3 жил өмнө
parent
commit
e8bed808a3

+ 41 - 22
miniprogram/pages/channelAdvertising/components/hangyezhanbi/F2.ts

@@ -8,20 +8,39 @@ namespace hangyezhanbi {
     upLine() {
       if (chartCatch.toufangfenxiChart === undefined) return
       chartCatch.toufangfenxiChart.clear()
-      
-      const data = this.data.DayList.map((v:any)=>{
-        v.type = "1"
+      let total = 0;
+      let key = this.data.select[this.data.select_act].proportionType;
+      let data = this.data.DayList.map((v:any)=>{
+        v.type = "1";
+      total += Number(v[key] || 0)
         return v
       });
+        data = data.map((v:any)=>{
+        v.p = Number(v[key]/total*100).toFixed(2)
+        return v
+      })
       if (chartCatch.toufangfenxiChart === undefined) return;
-      let key = this.data.select[this.data.select_act].proportionType;
       chartCatch.toufangfenxiChart.source(data);
       chartCatch.toufangfenxiChart.coord('polar', {
         transposed: true,
         innerRadius: 0.4,
         radius: 0.75
       });
-      chartCatch.toufangfenxiChart.legend(false);
+      chartCatch.toufangfenxiChart.legend({
+        position: 'bottom',
+        align: 'center',
+        itemFormatter: function itemFormatter(val: string) {
+          let p :any= {};
+          for (let i = 0; i < data.length; i++) {
+            const v = data[i];
+            if (v.industry === val) {
+              p = v
+              break
+            }
+        }
+          return val + '  ' + p.p + "% ";
+        }
+      });
       chartCatch.toufangfenxiChart.axis(false);
       chartCatch.toufangfenxiChart.tooltip({
         showCrosshairs: false,
@@ -34,23 +53,23 @@ namespace hangyezhanbi {
           items[0].value = formmaterValueZhou(items[0].value, 2);
         }
       });
-      chartCatch.toufangfenxiChart.pieLabel({
-        sidePadding: 10,
-        label1: function label1(label1:any) {
-          return {
-            text: label1.industry,
-            fill: '#666'
-          };
-        },
-        label2: function label2(label1:any) {
-          return {
-            fill: '#000000',
-            text: formmaterValueZhou(label1[key], 2),
-            fontWeight: 500,
-            fontSize: 10
-          };
-        }
-      });
+      // chartCatch.toufangfenxiChart.pieLabel({
+      //   sidePadding: 10,
+      //   label1: function label1(label1:any) {
+      //     return {
+      //       text: label1.industry,
+      //       fill: '#666'
+      //     };
+      //   },
+      //   label2: function label2(label1:any) {
+      //     return {
+      //       fill: '#000000',
+      //       text: formmaterValueZhou(label1[key], 2),
+      //       fontWeight: 500,
+      //       fontSize: 10
+      //     };
+      //   }
+      // });
       chartCatch.toufangfenxiChart.interval().position('type*' + key)
         .color('industry', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0', '#3436C7', '#223273'])
         .adjust('stack')