From 49f09cc6f8ff8c30a75ed1a9d6f510b69b73962a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 12 十二月 2023 21:05:37 +0800
Subject: [PATCH] 2023-12-12

---
 src/tabviews/custom/components/chart/antv-bar-line/index.jsx |  284 ++++++++------------------------------------------------
 1 files changed, 41 insertions(+), 243 deletions(-)

diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
index 1814eb8..f86a91e 100644
--- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
+++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
@@ -689,149 +689,43 @@
     }, 100)
   }
 
-  /**
-   * @description 鍥捐〃鏁版嵁棰勫鐞�
-   * 1銆侀�氳繃鏄剧ず鍒楄繘琛屾暟鎹被鍨嬭浆鎹�
-   * 2銆侀噸澶嶆暟鎹細鍙栧钩鍧囧�笺�佺疮璁°�佸幓閲�
-   * 3銆佹煴鐘跺浘鏁版嵁琛ラ綈
-   */
   getdata = () => {
     const { plot, vFields, config } = this.state
 
     if (this.data.length === 0) {
       this.setState({empty: true})
       return []
+    } else {
+      this.setState({empty: false})
     }
 
-    let _data = []
-    let _cdata = fromJS(this.data).toJS()
+    return fromJS(this.data).toJS().map(item => {
+      // dodge is not support linear attribute, please use category attribute! 鏃堕棿鏍煎紡
+      if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
+        item[plot.Xaxis] = ' ' + item[plot.Xaxis]
+      } else {
+        item[plot.Xaxis] = '' + item[plot.Xaxis]
+      }
 
-    if (plot.repeat === 'average') {
-      let _mdata = new Map()
-      _cdata.forEach(item => {
-        if (!item[plot.Xaxis] && item[plot.Xaxis] !== 0) return
-
-        vFields.forEach(col => {
-          if (typeof(item[col.field]) !== 'number') {
-            item[col.field] = parseFloat(item[col.field])
-            if (isNaN(item[col.field])) {
-              item[col.field] = 0
-            }
+      vFields.forEach(col => {
+        if (typeof(item[col.field]) !== 'number') {
+          item[col.field] = parseFloat(item[col.field])
+          if (isNaN(item[col.field])) {
+            item[col.field] = 0
           }
-          if (col.show === 'percent') {
-            item[col.field] = item[col.field] * 100
-          }
-        })
-
-        // dodge is not support linear attribute, please use category attribute! 鏃堕棿鏍煎紡
-        if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
-          item[plot.Xaxis] = ' ' + item[plot.Xaxis]
-        } else {
-          item[plot.Xaxis] = '' + item[plot.Xaxis]
+        }
+        if (col.show === 'percent') {
+          item[col.field] = item[col.field] * 100
         }
 
-        if (!_mdata.has(item[plot.Xaxis])) {
-          item.$count = 1
-          _mdata.set(item[plot.Xaxis], item)
-        } else {
-          let _item = _mdata.get(item[plot.Xaxis])
-          _item.$count++
-          vFields.forEach(col => {
-            _item[col.field] += item[col.field]
-          })
-          _mdata.set(item[plot.Xaxis], _item)
-        }
+        item[col.field] = item[col.field].toFixed(col.decimal)
+        item[col.field] = +item[col.field]
       })
 
-      _data = [..._mdata.values()]
-      _data = _data.map(item => {
-        vFields.forEach(col => {
-          item[col.field] = item[col.field] / item.$count
-          item[col.field] = item[col.field].toFixed(col.decimal)
-          item[col.field] = +item[col.field]
-        })
-        item.$$uuid = item[config.setting.primaryKey] || ''
-        return item
-      })
-    } else if (plot.repeat === 'cumsum') {
-      let _mdata = new Map()
-      _cdata.forEach(item => {
-        if (!item[plot.Xaxis] && item[plot.Xaxis] !== 0) return
+      item.$$uuid = item[config.setting.primaryKey] || ''
 
-        vFields.forEach(col => {
-          if (typeof(item[col.field]) !== 'number') {
-            item[col.field] = parseFloat(item[col.field])
-            if (isNaN(item[col.field])) {
-              item[col.field] = 0
-            }
-          }
-          if (col.show === 'percent') {
-            item[col.field] = item[col.field] * 100
-          }
-        })
-
-        if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
-          item[plot.Xaxis] = ' ' + item[plot.Xaxis]
-        } else {
-          item[plot.Xaxis] = '' + item[plot.Xaxis]
-        }
-
-        if (!_mdata.has(item[plot.Xaxis])) {
-          _mdata.set(item[plot.Xaxis], item)
-        } else {
-          let _item = _mdata.get(item[plot.Xaxis])
-          vFields.forEach(col => {
-            _item[col.field] += item[col.field]
-          })
-          _mdata.set(item[plot.Xaxis], _item)
-        }
-      })
-
-      _data = [..._mdata.values()]
-      _data = _data.map(item => {
-        vFields.forEach(col => {
-          item[col.field] = item[col.field].toFixed(col.decimal)
-          item[col.field] = +item[col.field]
-        })
-        item.$$uuid = item[config.setting.primaryKey] || ''
-        return item
-      })
-    } else { // plot.repeat === 'unrepeat'
-      let _mdata = new Map()
-      _cdata.forEach(item => {
-        if (!item[plot.Xaxis] && item[plot.Xaxis] !== 0) return
-
-        if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
-          item[plot.Xaxis] = ' ' + item[plot.Xaxis]
-        } else {
-          item[plot.Xaxis] = '' + item[plot.Xaxis]
-        }
-
-        if (!_mdata.has(item[plot.Xaxis])) {
-          vFields.forEach(col => {
-            if (typeof(item[col.field]) !== 'number') {
-              item[col.field] = parseFloat(item[col.field])
-              if (isNaN(item[col.field])) {
-                item[col.field] = 0
-              }
-            }
-            if (col.show === 'percent') {
-              item[col.field] = item[col.field] * 100
-            }
-            item[col.field] = item[col.field].toFixed(col.decimal)
-            item[col.field] = +item[col.field]
-          })
-          
-          item.$$uuid = item[config.setting.primaryKey] || ''
-          _mdata.set(item[plot.Xaxis], item)
-        }
-      })
-
-      _data = [..._mdata.values()]
-    }
-
-    this.setState({empty: _data.length === 0})
-    return _data
+      return item
+    })
   }
 
   /**
@@ -840,132 +734,36 @@
   getStaticMsg = () => {
     const { plot, vstFields } = this.state
 
-    let percent = false
-    let decimal = vstFields ? vstFields.decimal : 0
-
-    if (plot.show === 'percent') {
-      percent = true
-    }
-
     if (this.data.length === 0) {
       this.setState({empty: true})
       return []
+    } else {
+      this.setState({empty: false})
     }
 
-    let _data = []
-    let _cdata = fromJS(this.data).toJS()
+    let decimal = vstFields ? vstFields.decimal : 0
 
-    if (plot.repeat === 'average') {
-      let _mdata = new Map()
-      _cdata.forEach(item => {
-        if (!item[plot.InfoType] || !item[plot.Xaxis]) return
+    return fromJS(this.data).toJS().map(item => {
+      if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
+        item[plot.Xaxis] = ' ' + item[plot.Xaxis]
+      }
 
-        if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
-          item[plot.Xaxis] = ' ' + item[plot.Xaxis]
+      if (typeof(item[plot.InfoValue]) !== 'number') {
+        item[plot.InfoValue] = parseFloat(item[plot.InfoValue])
+        if (isNaN(item[plot.InfoValue])) {
+          item[plot.InfoValue] = 0
         }
+      }
 
-        item.$uuid = item[plot.InfoType] + item[plot.Xaxis]
-        if (typeof(item[plot.InfoValue]) !== 'number') {
-          item[plot.InfoValue] = parseFloat(item[plot.InfoValue])
-          if (isNaN(item[plot.InfoValue])) {
-            item[plot.InfoValue] = 0
-          }
-        }
-        if (percent) {
-          item[plot.InfoValue] = item[plot.InfoValue] * 100
-        }
+      if (plot.show === 'percent') {
+        item[plot.InfoValue] = item[plot.InfoValue] * 100
+      }
 
-        if (!_mdata.has(item.$uuid)) {
-          item.$count = 1
-          _mdata.set(item.$uuid, item)
-        } else {
-          let _item = _mdata.get(item.$uuid)
-          _item.$count++
-          _item[plot.InfoValue] += item[plot.InfoValue]
-          _mdata.set(item.$uuid, _item)
-        }
-      })
+      item[plot.InfoValue] = item[plot.InfoValue].toFixed(decimal)
+      item[plot.InfoValue] = +item[plot.InfoValue]
 
-      _data = [..._mdata.values()]
-      _data = _data.map(item => {
-        item[plot.InfoValue] = item[plot.InfoValue] / item.$count
-        item[plot.InfoValue] = item[plot.InfoValue].toFixed(decimal)
-        item[plot.InfoValue] = +item[plot.InfoValue]
-
-        return item
-      })
-    } else if (plot.repeat === 'cumsum') {
-      let _mdata = new Map()
-      _cdata.forEach(item => {
-        if (!item[plot.InfoType] || !item[plot.Xaxis]) return
-
-        if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
-          item[plot.Xaxis] = ' ' + item[plot.Xaxis]
-        }
-
-        item.$uuid = item[plot.InfoType] + item[plot.Xaxis]
-
-        if (typeof(item[plot.InfoValue]) !== 'number') {
-          item[plot.InfoValue] = parseFloat(item[plot.InfoValue])
-          if (isNaN(item[plot.InfoValue])) {
-            item[plot.InfoValue] = 0
-          }
-        }
-        if (percent) {
-          item[plot.InfoValue] = item[plot.InfoValue] * 100
-        }
-
-        if (!_mdata.has(item.$uuid)) {
-          _mdata.set(item.$uuid, item)
-        } else {
-          let _item = _mdata.get(item.$uuid)
-          _item[plot.InfoValue] += item[plot.InfoValue]
-          _mdata.set(item.$uuid, _item)
-        }
-      })
-
-      _data = [..._mdata.values()]
-      _data = _data.map(item => {
-        item[plot.InfoValue] = item[plot.InfoValue].toFixed(decimal)
-        item[plot.InfoValue] = +item[plot.InfoValue]
-
-        return item
-      })
-    } else { // plot.repeat === 'unrepeat'
-      let _mdata = new Map()
-      _cdata.forEach(item => {
-        if (!item[plot.InfoType] || !item[plot.Xaxis]) return
-
-        if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
-          item[plot.Xaxis] = ' ' + item[plot.Xaxis]
-        }
-
-        item.$uuid = item[plot.InfoType] + item[plot.Xaxis]
-
-        if (!_mdata.has(item.$uuid)) {
-          if (typeof(item[plot.InfoValue]) !== 'number') {
-            item[plot.InfoValue] = parseFloat(item[plot.InfoValue])
-            if (isNaN(item[plot.InfoValue])) {
-              item[plot.InfoValue] = 0
-            }
-          }
-          if (percent) {
-            item[plot.InfoValue] = item[plot.InfoValue] * 100
-          }
-
-          item[plot.InfoValue] = item[plot.InfoValue].toFixed(decimal)
-          item[plot.InfoValue] = +item[plot.InfoValue]
-
-          _mdata.set(item.$uuid, item)
-        }
-      })
-
-      _data = [..._mdata.values()]
-    }
-
-    this.setState({empty: _data.length === 0})
-
-    return _data
+      return item
+    })
   }
 
   /**

--
Gitblit v1.8.0