From 15acad2194d616b37d85dd6192bc5656403f1a83 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 19 五月 2022 17:19:40 +0800
Subject: [PATCH] 2022-05-19

---
 src/menu/components/chart/antv-bar/chartcompile/index.jsx |   70 +++++++++++++++++++++++++----------
 1 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/src/menu/components/chart/antv-bar/chartcompile/index.jsx b/src/menu/components/chart/antv-bar/chartcompile/index.jsx
index b2d1d56..61f053f 100644
--- a/src/menu/components/chart/antv-bar/chartcompile/index.jsx
+++ b/src/menu/components/chart/antv-bar/chartcompile/index.jsx
@@ -497,17 +497,39 @@
         if (!err) {
           let _plot = {...plot, ...values}
 
-          if (values.datatype === 'statistics' || values.datatype !== plot.datatype) {
-            _plot.enabled = 'false'
-            _plot.customs = []
-          } else if (!values.Yaxis || !plot.Yaxis || !is(fromJS(values.Yaxis), fromJS(plot.Yaxis))) {
-            _plot.enabled = 'false'
-            _plot.customs = []
-            _plot.colors = null
-          }
-
           if (values.datatype !== plot.datatype) {
             _plot.colors = null
+          }
+          if (values.datatype === 'statistics') {
+            _plot.enabled = 'false'
+            _plot.customs = []
+            delete _plot.Yaxis
+          } else if (!is(fromJS(values.Yaxis), fromJS(plot.Yaxis || []))) {
+            _plot.enabled = 'false'
+            _plot.colors = null
+
+            let labels = {}
+            config.columns.forEach(col => {
+              labels[col.field] = col.label
+            })
+  
+            let cus = {}
+            _plot.customs && _plot.customs.forEach(m => {
+              cus[m.type] = m
+            })
+            _plot.customs = _plot.Yaxis.map((item, i) => {
+              if (cus[item]) return cus[item]
+              
+              return {
+                uuid: Utils.getuuid(),
+                type: item,
+                name: labels[item] || item,
+                axis: i === 0 ? 'true' : 'false',
+                label: 'false',
+                title: 'true',
+                shape: _plot.chartType === 'bar' && i === 0 ? ['bar', 'rect'] : ['line', 'smooth']
+              }
+            })
           }
 
           this.setState({
@@ -580,22 +602,29 @@
         if (!err) {
           let _plot = {...plot, ...values}
 
-          if (values.datatype === 'statistics' || values.datatype !== plot.datatype) {
-            _plot.enabled = 'false'
-            _plot.customs = []
-          } else if (!values.Yaxis || !plot.Yaxis || !is(fromJS(values.Yaxis), fromJS(plot.Yaxis))) {
-            _plot.enabled = 'false'
-            _plot.customs = []
-            _plot.colors = null
-          }
-
           let labels = {}
           config.columns.forEach(col => {
             labels[col.field] = col.label
           })
 
-          if (values.datatype !== 'statistics' && (!_plot.customs || _plot.customs.length === 0)) {
+          if (values.datatype !== plot.datatype) {
+            _plot.colors = null
+          }
+          if (values.datatype === 'statistics') {
+            _plot.enabled = 'false'
+            _plot.customs = []
+            delete _plot.Yaxis
+          } else if (!is(fromJS(values.Yaxis), fromJS(plot.Yaxis || []))) {
+            _plot.enabled = 'false'
+            _plot.colors = null
+
+            let cus = {}
+            _plot.customs && _plot.customs.forEach(m => {
+              cus[m.type] = m
+            })
             _plot.customs = _plot.Yaxis.map((item, i) => {
+              if (cus[item]) return cus[item]
+              
               return {
                 uuid: Utils.getuuid(),
                 type: item,
@@ -607,7 +636,8 @@
               }
             })
           }
-          if (values.datatype !== plot.datatype || !_plot.colors) {
+
+          if (!_plot.colors) {
             _plot.colors = []
             if (_plot.datatype === 'query') {
               let limit = chartColors.length

--
Gitblit v1.8.0