فهرست منبع

遗漏文件提交

zhuth 6 سال پیش
والد
کامیت
de7acc6589
1فایلهای تغییر یافته به همراه39 افزوده شده و 20 حذف شده
  1. 39 20
      src/models/parseChartOption.js

+ 39 - 20
src/models/parseChartOption.js

@@ -8,7 +8,7 @@ import STATISTICS_OPTION from '../components/chartDesigner/sections/statisticsOp
 import themes from '../components/chartDesigner/sections/style/theme/index'
 import EChartsMedia from './EChartsMedia'
 
-export default function(viewType, data, chartConfig, themeName, styleConfig) {
+export default function(viewType, data, chartConfig, themeName, styleConfig, chartDesigner) {
     if(!data) {
         return {};
     }
@@ -63,24 +63,20 @@ function barOption(data, barConfig, themeConfig, styleConfig) {
         xLabelMargin, yNameLocation, yNameGap, yNameRotate, labelZeroVisible } = styleConfig;
     let xTitle = xAxis?`${xAxis.column.label}`:null
     let yTitle = yAxis?`${yAxis.column.label}`:null
-    let legendVisible = !!groupBy && !!groupBy.key;
+    let hasGroupBy = !!groupBy && !!groupBy.key;
+    let legendVisible = hasGroupBy;
     data.serieses = data.serieses || [];
 
     let option = deepAssign({
+        originConfig: {
+            xAxis,
+            yAxis,
+            groupBy,
+        },
         tooltip : {
             trigger: "axis",
             axisPointer: {
                 type: "cross"
-            // },
-            // formatter: function (params, ticket, callback) {
-            //     var str = `${params[0].name}<br />`;
-            //     params.forEach((p) => {
-            //         const { marker, seriesName, value } = p;
-            //         if(value !== undefined) {
-            //             str += `${marker}${seriesName}: ${value}<br />`
-            //         }
-            //     });
-            //     return str;
             }
         },
         legend: {
@@ -165,10 +161,16 @@ function lineOption(data, lineConfig, themeConfig, styleConfig) {
     const { xAxis, yAxis, groupBy } = lineConfig;
     let xTitle = xAxis?`${xAxis.column.label}${xAxis.granularity.value?'('+xAxis.granularity.label+')':''}`:null
     let yTitle = yAxis?`${yAxis.column.label}${yAxis.gauge.value?'('+yAxis.gauge.label+')':''}`:null
-    let legendVisible = !!groupBy && !!groupBy.key;
+    let hasGroupBy = !!groupBy && !!groupBy.key;
+    let legendVisible = hasGroupBy;
     data.serieses = data.serieses || [];
 
     let option = deepAssign({
+        originConfig: {
+            xAxis,
+            yAxis,
+            groupBy
+        },
         tooltip : {
             trigger: "axis",
             axisPointer: {
@@ -249,9 +251,13 @@ function lineOption(data, lineConfig, themeConfig, styleConfig) {
 
 function pieOption(data, pieConfig, themeConfig, styleConfig) {
     let { labelHidden } = styleConfig;
-    let columnName = pieConfig.xAxis.column.label + (pieConfig.xAxis.granularity.value ? '('+pieConfig.xAxis.granularity.label+')' : '');
-
+    let { xAxis, yAxis } = pieConfig;
+    let columnName = xAxis.column.label;
     let option = deepAssign({
+        originConfig: {
+            xAxis,
+            yAxis,
+        },
         tooltip : {
             trigger: 'item',
             formatter: "{a} <br/>{b} : {c} ({d}%)"
@@ -322,10 +328,16 @@ function scatterOption(data, scatterConfig, themeConfig, styleConfig) {
     const { labelSymbol, xNameLocation, xNameGap, xNameRotate, yNameLocation, yNameGap, yNameRotate, labelSymbolSize, dataZoomVisible } = styleConfig;
     const { xAxis, yAxis, groupBy } = scatterConfig;
     let xTitle = xAxis?`${xAxis.column.label}${xAxis.granularity.value?'('+xAxis.granularity.label+')':''}`:null
-    let yTitle = yAxis?`${yAxis.column.label}${yAxis.gauge.value?'('+yAxis.gauge.label+')':''}`:null
-    let legendVisible = !!groupBy && !!groupBy.key
+    let yTitle = yAxis?`${yAxis.column.label}${yAxis.gauge.value?'('+yAxis.gauge.label+')':''}`:null;
+    let hasGroupBy = !!groupBy && !!groupBy.key;
+    let legendVisible = hasGroupBy;
     
     let option = deepAssign({
+        originConfig: {
+            xAxis,
+            yAxis,
+            groupBy
+        },
         tooltip: {
             trigger: 'axis',
             axisPointer: {
@@ -441,7 +453,6 @@ function aggregateTableOption( data, aggregateTableConfig, themeConfig, styleCon
                     o[group2Name] = g;
                     statistics.forEach(s => {
                         let v = list.find(l => l[group2Name] === g);
-                        console.log(v);
                         o[s.name] = v ? (typeof v[s.name] === 'number' ? numberFormat(v[s.name]) : '') : '';
                     });
                     return o;
@@ -453,6 +464,11 @@ function aggregateTableOption( data, aggregateTableConfig, themeConfig, styleCon
     }
 
     let option = {
+        originConfig: {
+            targetColumn,
+            groupBy,
+            statistics,
+        },
         themeConfig,
         targetColumn,
         direction: direction || 'horizontal',
@@ -469,11 +485,14 @@ function aggregateTableOption( data, aggregateTableConfig, themeConfig, styleCon
 
 function dataViewOption(data, dataViewConfig, themeConfig, styleConfig) {
     const { list, pageNum, pageSize, pages, total } = data.valueList;
-
-    let columns = dataViewConfig.viewColumns || [];
+    let { viewColumns } = dataViewConfig;
+    let columns = viewColumns || [];
     let dataSource = list || [];
 
     let option = {
+        originConfig: {
+            viewColumns
+        },
         columns: columns.map(c => {
             let obj = {
                 title: c.label,