From 2188694b8aca0139463a7bcdc876ab0a1208417c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 13 十二月 2023 16:13:44 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/tabviews/custom/components/chart/antv-pie/index.jsx |  232 +++++++++------------------------------------------------
 1 files changed, 37 insertions(+), 195 deletions(-)

diff --git a/src/tabviews/custom/components/chart/antv-pie/index.jsx b/src/tabviews/custom/components/chart/antv-pie/index.jsx
index f589d40..2602e4d 100644
--- a/src/tabviews/custom/components/chart/antv-pie/index.jsx
+++ b/src/tabviews/custom/components/chart/antv-pie/index.jsx
@@ -353,8 +353,6 @@
   /**
    * @description 鍥捐〃鏁版嵁棰勫鐞�
    * 1銆侀�氳繃鏄剧ず鍒楄繘琛屾暟鎹被鍨嬭浆鎹�
-   * 2銆侀噸澶嶆暟鎹細鍙栧钩鍧囧�笺�佺疮璁°�佸幓閲�
-   * 3銆佹煴鐘跺浘鏁版嵁琛ラ綈
    */
   getdata = () => {
     const { plot } = this.state
@@ -362,91 +360,22 @@
     if (this.data.length === 0) {
       this.setState({empty: true})
       return []
+    } else {
+      this.setState({empty: false})
     }
 
-    let _data = []
-    let _cdata = fromJS(this.data).toJS()
-
-    if (plot.repeat === 'average') {
-      let _mdata = new Map()
-      _cdata.forEach(item => {
-        if (typeof(item[plot.Yaxis]) !== 'number') {
-          item[plot.Yaxis] = parseFloat(item[plot.Yaxis])
-          if (isNaN(item[plot.Yaxis])) {
-            return
-          }
-        } else if (!item[plot.Xaxis]) {
-          return
+    return fromJS(this.data).toJS().map(item => {
+      if (typeof(item[plot.Yaxis]) !== 'number') {
+        item[plot.Yaxis] = parseFloat(item[plot.Yaxis])
+        if (isNaN(item[plot.Yaxis])) {
+          item[plot.Yaxis] = 0
         }
+      }
 
-        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++
-          _item[plot.Yaxis] += item[plot.Yaxis]
-          _mdata.set(item[plot.Xaxis], _item)
-        }
-      })
+      item[plot.Yaxis] = +item[plot.Yaxis].toFixed(plot.$decimal)
 
-      _data = [..._mdata.values()]
-      _data = _data.map(item => {
-        item[plot.Yaxis] = item[plot.Yaxis] / item.$count
-        item[plot.Yaxis] = +item[plot.Yaxis].toFixed(plot.$decimal)
-
-        return item
-      })
-    } else if (plot.repeat === 'cumsum') {
-      let _mdata = new Map()
-      _cdata.forEach(item => {
-        if (typeof(item[plot.Yaxis]) !== 'number') {
-          item[plot.Yaxis] = parseFloat(item[plot.Yaxis])
-          if (isNaN(item[plot.Yaxis])) {
-            return
-          }
-        } else if (!item[plot.Xaxis]) {
-          return
-        }
-
-        if (!_mdata.has(item[plot.Xaxis])) {
-          _mdata.set(item[plot.Xaxis], item)
-        } else {
-          let _item = _mdata.get(item[plot.Xaxis])
-          _item[plot.Yaxis] += item[plot.Yaxis]
-          _mdata.set(item[plot.Xaxis], _item)
-        }
-      })
-
-      _data = [..._mdata.values()]
-      _data = _data.map(item => {
-        item[plot.Yaxis] = +item[plot.Yaxis].toFixed(plot.$decimal)
-        return item
-      })
-    } else { // plot.repeat === 'unrepeat'
-      let _mdata = new Map()
-      _cdata.forEach(item => {
-        if (!item[plot.Xaxis] || _mdata.has(item[plot.Xaxis])) {
-          return
-        }
-        if (typeof(item[plot.Yaxis]) !== 'number') {
-          item[plot.Yaxis] = parseFloat(item[plot.Yaxis])
-          if (isNaN(item[plot.Yaxis])) {
-            return
-          }
-        }
-
-        item[plot.Yaxis] = +item[plot.Yaxis].toFixed(plot.$decimal)
-
-        _mdata.set(item[plot.Xaxis], item)
-      })
-
-      _data = [..._mdata.values()]
-    }
-
-    this.setState({empty: _data.length === 0})
-
-    return _data
+      return item
+    })
   }
 
   getnestdata = () => {
@@ -458,127 +387,40 @@
     }
 
     let _data = []
-    let _cdata = fromJS(this.data).toJS()
 
-    if (plot.repeat === 'average') {
-      let _mdata = new Map()
-      let map = new Map()
-      let sort = 1
-      _cdata.forEach(item => {
-        if (typeof(item[plot.Yaxis]) !== 'number') {
-          item[plot.Yaxis] = parseFloat(item[plot.Yaxis])
-          if (isNaN(item[plot.Yaxis])) {
-            return
-          }
-        } else if (!item[plot.Xaxis] || !item[plot.type]) {
+    let _mdata = new Map()
+    let map = new Map()
+    let sort = 1
+    fromJS(this.data).toJS().forEach(item => {
+      let sign = item[plot.type] + item[plot.Xaxis]
+      if (!item[plot.Xaxis] || !item[plot.type] || _mdata.has(sign)) {
+        return
+      }
+
+      if (typeof(item[plot.Yaxis]) !== 'number') {
+        item[plot.Yaxis] = parseFloat(item[plot.Yaxis])
+        if (isNaN(item[plot.Yaxis])) {
           return
         }
+      }
 
-        item.$type = item[plot.type]
-        let sign = item.$type + item[plot.Xaxis]
+      item.$type = item[plot.type]
 
-        if (!_mdata.has(sign)) {
-          let _sort = sort
-          if (map.has(item.$type)) {
-            _sort = map.get(item.$type)
-          } else {
-            map.set(item.$type, _sort)
-            sort++
-          }
+      let _sort = sort
+      if (map.has(item.$type)) {
+        _sort = map.get(item.$type)
+      } else {
+        map.set(item.$type, _sort)
+        sort++
+      }
 
-          item.$count = 1
-          item.$sort = _sort
-          _mdata.set(sign, item)
-        } else {
-          let _item = _mdata.get(sign)
-          _item.$count++
-          _item[plot.Yaxis] += item[plot.Yaxis]
-          _mdata.set(sign, _item)
-        }
-      })
+      item.$sort = _sort
+      item[plot.Yaxis] = +item[plot.Yaxis].toFixed(plot.$decimal)
 
-      _data = [..._mdata.values()]
-      _data = _data.map(item => {
-        item[plot.Yaxis] = item[plot.Yaxis] / item.$count
-        item[plot.Yaxis] = +item[plot.Yaxis].toFixed(plot.$decimal)
+      _mdata.set(sign, true)
 
-        return item
-      })
-    } else if (plot.repeat === 'cumsum') {
-      let _mdata = new Map()
-      let map = new Map()
-      let sort = 1
-      _cdata.forEach(item => {
-        if (typeof(item[plot.Yaxis]) !== 'number') {
-          item[plot.Yaxis] = parseFloat(item[plot.Yaxis])
-          if (isNaN(item[plot.Yaxis])) {
-            return
-          }
-        } else if (!item[plot.Xaxis] || !item[plot.type]) {
-          return
-        }
-
-        item.$type = item[plot.type]
-        let sign = item.$type + item[plot.Xaxis]
-
-        if (!_mdata.has(sign)) {
-          let _sort = sort
-          if (map.has(item.$type)) {
-            _sort = map.get(item.$type)
-          } else {
-            map.set(item.$type, _sort)
-            sort++
-          }
-
-          item.$sort = _sort
-          _mdata.set(sign, item)
-        } else {
-          let _item = _mdata.get(sign)
-          _item[plot.Yaxis] += item[plot.Yaxis]
-          _mdata.set(sign, _item)
-        }
-      })
-
-      _data = [..._mdata.values()]
-      _data = _data.map(item => {
-        item[plot.Yaxis] = +item[plot.Yaxis].toFixed(plot.$decimal)
-        return item
-      })
-    } else { // plot.repeat === 'unrepeat'
-      let _mdata = new Map()
-      let map = new Map()
-      let sort = 1
-      _cdata.forEach(item => {
-        let sign = item[plot.type] + item[plot.Xaxis]
-        if (!item[plot.Xaxis] || !item[plot.type] || _mdata.has(sign)) {
-          return
-        }
-
-        if (typeof(item[plot.Yaxis]) !== 'number') {
-          item[plot.Yaxis] = parseFloat(item[plot.Yaxis])
-          if (isNaN(item[plot.Yaxis])) {
-            return
-          }
-        }
-
-        item.$type = item[plot.type]
-
-        let _sort = sort
-        if (map.has(item.$type)) {
-          _sort = map.get(item.$type)
-        } else {
-          map.set(item.$type, _sort)
-          sort++
-        }
-
-        item.$sort = _sort
-        item[plot.Yaxis] = +item[plot.Yaxis].toFixed(plot.$decimal)
-
-        _mdata.set(sign, item)
-      })
-
-      _data = [..._mdata.values()]
-    }
+      _data.push(item)
+    })
 
     this.setState({empty: _data.length === 0})
 

--
Gitblit v1.8.0