Browse Source

【bug】饼图null显示为空

zhuth 6 years ago
parent
commit
b3a00529f1
1 changed files with 6 additions and 4 deletions
  1. 6 4
      src/models/parseChartOption.js

+ 6 - 4
src/models/parseChartOption.js

@@ -111,19 +111,20 @@ function barOption(data, barConfig) {
 
 function pieOption(data, pieConfig) {
     let columnName = pieConfig.xAxis.column.label + (pieConfig.xAxis.granularity.value ? '('+pieConfig.xAxis.granularity.label+')' : '');
-                    
+      
+    console.log(pieConfig);
     let option = {
         tooltip : {
             trigger: 'item',
             formatter: "{a} <br/>{b} : {c} ({d}%)"
         },
         legend: {
-            data: data.xAxis
+            data: (data.xAxis || []).map(d => d || '空')
         },
         grid: {
             left: '10%',
             right: '10%',
-            top: 60,
+            top: 100,
             bottom: 60,
             containLabel: true
         },
@@ -133,7 +134,7 @@ function pieOption(data, pieConfig) {
                 type: 'pie',
                 // radius : '55%',
                 // center: ['50%', '60%'],
-                data: (data.serieses || [])[0].value,
+                data: (data.serieses || [{ value: [] }])[0].value.map(v => ({ ...v, name: v.name || '空' })),
                 itemStyle: {
                     emphasis: {
                         shadowBlur: 10,
@@ -145,6 +146,7 @@ function pieOption(data, pieConfig) {
         ]
     };
 
+    console.log(option);
     return option;
 }