From cc810edac6aec3c858fb352091ad8c11332447a5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 10 十二月 2023 19:12:53 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/tabviews/custom/components/chart/antv-bar-line/index.jsx |  297 ++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 231 insertions(+), 66 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 cfe93bc..1814eb8 100644
--- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
+++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
@@ -100,6 +100,15 @@
     _config.style.height = 'auto'
     _config.style.minHeight = _config.plot.height + 30
 
+    if (_config.plot.correction) {
+      delete _config.plot.correction // 鏁版嵁淇锛堝凡寮冪敤锛�
+      _config.plot.barSize = 35
+    }
+
+    if (!_config.plot.legend || _config.plot.legend === 'hidden') {
+      _config.plot.legend = false
+    }
+
     if (_config.plot.title) {
       _config.style.minHeight = _config.style.minHeight + 45
     }
@@ -133,6 +142,38 @@
 
       if (_config.plot.mutilBar !== 'overlap' && Bar_axis.length > 1) {
         _config.plot.Bar_axis = Bar_axis
+      }
+
+      if (_config.plot.Bar_axis && _config.plot.Bar_axis.length) {
+        let label = _config.plot.label
+
+        if (label === 'false') {
+          _config.plot.customs.forEach(item => {
+            if (!Bar_axis.includes(item.type)) return
+            if (item.label === 'true') {
+              label = 'true'
+            }
+          })
+        } else {
+          let reset = true
+          _config.plot.customs.forEach(item => {
+            if (!Bar_axis.includes(item.type)) return
+            if (item.label === 'true') {
+              reset = false
+            }
+          })
+          if (reset) {
+            label = 'false'
+          }
+        }
+
+        _config.plot.$label = label
+      }
+
+      if (_config.plot.zoomYaxis === 'adjust' && _config.plot.mutilBar === 'stack') {
+        if (_config.plot.Bar_axis) {
+          _config.plot.zoomFields = _config.plot.Yaxis.filter(cell => !_config.plot.Bar_axis.includes(cell))
+        }
       }
     } else {
       _config.plot.enabled = 'false'
@@ -1018,7 +1059,7 @@
     chart.axis(plot.Xaxis, plot.$xc)
     chart.axis(_valfield, plot.$yc)
 
-    if (!plot.legend || plot.legend === 'hidden') {
+    if (!plot.legend) {
       chart.legend(false)
     } else {
       chart.legend({
@@ -1051,9 +1092,17 @@
       .position(`${plot.Xaxis}*${_valfield}`)
       .shape(plot.shape || 'smooth')
       .tooltip(`${plot.Xaxis}*${_valfield}*${_typefield}`, (name, value, type) => {
+        let val = value
+        if (plot.show === 'percent') {
+          val = value + '%'
+        } else if (plot.show === 'thdSeparator') {
+          val = val + ''
+          val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
+        }
+
         return {
           name: type,
-          value: plot.show === 'percent' ? value + '%' : value
+          value: val
         }
       })
 
@@ -1075,14 +1124,15 @@
     }
     if (plot.label !== 'false') {
       _chart.label(_valfield, (value) => {
-        if (plot.labelValue === 'zero' && value === 0) {
-          return null
-        }
+        let val = value
         if (plot.show === 'percent') {
-          value = value + '%'
+          val = value + '%'
+        } else if (plot.show === 'thdSeparator') {
+          val = val + ''
+          val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
         }
         return {
-          content: value,
+          content: val,
           style: {
             fill: plot.color
           }
@@ -1153,6 +1203,41 @@
    */
   customrender = (data) => {
     const { plot, transfield } = this.state
+
+    let max = 0
+    if (plot.zoomYaxis === 'adjust') {
+      data.forEach(item => {
+        if (plot.zoomFields) {
+          plot.zoomFields.forEach(f => {
+            if (item[f] > max) {
+              max = item[f]
+            }
+          })
+          let sum = 0
+          plot.Bar_axis.forEach(f => {
+            sum += item[f]
+          })
+          if (sum > max) {
+            max = sum
+          }
+        } else {
+          plot.Yaxis.forEach(f => {
+            if (item[f] > max) {
+              max = item[f]
+            }
+          })
+        }
+      })
+
+      if (!isNaN(max)) {
+        max = Math.ceil(max)
+        let s = max > 10 ? Math.pow(10, (max + '').length - 2) : 1
+        max = Math.ceil(max / s) * s
+      } else {
+        max = 0
+      }
+    }
+
     const ds = new DataSet()
     const dv = ds.createView().source(data)
 
@@ -1187,8 +1272,7 @@
       })
     }
 
-    let noLegend = !plot.legend || plot.legend === 'hidden'
-    if (noLegend) {
+    if (!plot.legend) {
       chart.legend(false)
     } else {
       chart.legend({
@@ -1265,22 +1349,30 @@
         range: [0, 0.9]
       }
   
-      if (plot.min || plot.min === 0) {
-        c.min = plot.min
-      }
-      if (plot.max || plot.max === 0) {
-        c.max = plot.max
+      if (plot.zoomYaxis === 'adjust') {
+        if (max) {
+          c.min = 0
+          c.max = max
+        }
+      } else {
+        if (plot.min || plot.min === 0) {
+          c.min = plot.min
+        }
+        if (plot.max || plot.max === 0) {
+          c.max = plot.max
+          c.min = c.min || 0
+        }
       }
       view1.scale('value', c)
       view1.axis('value', plot.$yc)
   
-      if (!noLegend) {
+      if (plot.legend) {
         view1.legend(false)
       }
 
       let colorIndex = 0
   
-      if (plot.adjust !== 'stack') {
+      if (plot.mutilBar !== 'stack') {
         let _chart = view1
           .interval()
           .position(`${plot.Xaxis}*value`)
@@ -1292,12 +1384,16 @@
           ])
           .shape(plot.shape || 'rect')
           .tooltip(`${plot.Xaxis}*value*key`, (name, value, key) => {
+            let val = value
             if (plot.show === 'percent') {
-              value = value + '%'
+              val = value + '%'
+            } else if (plot.show === 'thdSeparator') {
+              val = val + ''
+              val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
             }
             return {
               name: key,
-              value: value
+              value: val
             }
           })
 
@@ -1314,45 +1410,53 @@
         } else {
           _chart.color('key')
         }
-        if (plot.label !== 'false') {
+        if (plot.$label !== 'false') {
           _chart.label('value*key', (value, key) => {
-            if (plot.labelValue === 'zero' && value === 0) {
+            if (plot.$label !== 'true' && value === 0) {
               return null
             }
 
+            let val = value
             if (plot.show === 'percent') {
-              value = value + '%'
+              val = value + '%'
+            } else if (plot.show === 'thdSeparator') {
+              val = val + ''
+              val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
             }
 
-            if (plot.label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) {
+            if (plot.$label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) {
               lablecfg.style.fill = plot.$colors.get(key)
             }
             return {
-              content: value,
+              content: val,
               ...lablecfg
             }
           })
         }
 
-        if (plot.barSize || plot.correction) {
+        if (plot.barSize) {
           _chart.size(plot.barSize || 35)
         }
         if (plot.barRadius) {
           _chart.style({ radius: [plot.barRadius, plot.barRadius, 0, 0] })
         }
-      } else if (plot.adjust === 'stack') {
+      } else if (plot.mutilBar === 'stack') {
         let _chart = view1
           .interval()
           .position(`${plot.Xaxis}*value`)
           .adjust('stack')
           .shape(plot.shape || 'rect')
           .tooltip(`${plot.Xaxis}*value*key`, (name, value, type) => {
+            let val = value
             if (plot.show === 'percent') {
-              value = value + '%'
+              val = value + '%'
+            } else if (plot.show === 'thdSeparator') {
+              val = val + ''
+              val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
             }
             return {
               name: type,
-              value: value
+              value: val
             }
           })
   
@@ -1369,26 +1473,30 @@
         } else {
           _chart.color('key')
         }
-        if (plot.label !== 'false') {
+        if (plot.$label !== 'false') {
           _chart.label('value*key', (value, key) => {
-            if (plot.labelValue === 'zero' && value === 0) {
+            if (plot.$label !== 'true' && value === 0) {
               return null
             }
 
+            let val = value
             if (plot.show === 'percent') {
-              value = value + '%'
+              val = value + '%'
+            } else if (plot.show === 'thdSeparator') {
+              val = val + ''
+              val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
             }
-            if (plot.label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) {
+            if (plot.$label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) {
               lablecfg.style.fill = plot.$colors.get(key)
             }
             return {
-              content: value,
+              content: val,
               ...lablecfg
             }
           })
         }
 
-        if (plot.barSize || plot.correction) {
+        if (plot.barSize) {
           _chart.size(plot.barSize || 35)
         }
         if (plot.barRadius) {
@@ -1411,7 +1519,7 @@
 
     view2.data(dv.rows)
 
-    if (!noLegend) {
+    if (plot.legend && plot.Bar_axis) {
       view2.legend(false)
     }
 
@@ -1424,11 +1532,18 @@
           range: [0, 0.9]
         }
     
-        if (item.min || item.min === 0) {
-          c.min = item.min
-        }
-        if (item.max || item.max === 0) {
-          c.max = item.max
+        if (plot.zoomYaxis === 'adjust') {
+          if (max) {
+            c.min = 0
+            c.max = max
+          }
+        } else {
+          if (item.min || item.min === 0) {
+            c.min = item.min
+          }
+          if (item.max || item.max === 0) {
+            c.max = item.max
+          }
         }
 
         view2.scale(item.name, c)
@@ -1438,9 +1553,16 @@
           .color(item.color)
           .shape(item.shape)
           .tooltip(`${item.name}`, (value) => {
+            let val = value
+            if (item.show === 'percent') {
+              val = value + '%'
+            } else if (item.show === 'thdSeparator') {
+              val = val + ''
+              val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
+            }
             return {
               name: item.name,
-              value: item.show === 'percent' ? value + '%' : value
+              value: val
             }
           })
 
@@ -1449,18 +1571,22 @@
         }
         if (item.label !== 'false') {
           _chart.label(item.name, (value) => {
-            if (plot.labelValue === 'zero' && value === 0) {
+            if (plot.label !== 'true' && value === 0) {
               return null
             }
 
+            let val = value
             if (item.show === 'percent') {
-              value = value + '%'
+              val = value + '%'
+            } else if (item.show === 'thdSeparator') {
+              val = val + ''
+              val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
             }
             if (plot.label === 'true' && plot.labelColor === 'custom' && item.color) {
               lablecfg.style.fill = item.color
             }
             return {
-              content: value,
+              content: val,
               ...lablecfg
             }
           })
@@ -1479,11 +1605,18 @@
           range: [0, 0.9]
         }
     
-        if (item.min || item.min === 0) {
-          c.min = item.min
-        }
-        if (item.max || item.max === 0) {
-          c.max = item.max
+        if (plot.zoomYaxis === 'adjust') {
+          if (max) {
+            c.min = 0
+            c.max = max
+          }
+        } else {
+          if (item.min || item.min === 0) {
+            c.min = item.min
+          }
+          if (item.max || item.max === 0) {
+            c.max = item.max
+          }
         }
 
         view2.scale(item.name, c)
@@ -1493,23 +1626,32 @@
           .color(item.color)
           .shape(item.shape)
           .tooltip(`${item.name}`, (value) => {
+            let val = value
+            if (item.show === 'percent') {
+              val = value + '%'
+            } else if (item.show === 'thdSeparator') {
+              val = val + ''
+              val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
+            }
+
             return {
               name: item.name,
-              value: item.show === 'percent' ? value + '%' : value
+              value: val
             }
           })
 
         if (item.label === 'true') {
           _chart.label(item.name, (value) => {
-            if (plot.labelValue === 'zero' && value === 0) {
-              return null
+            let val = value
+            if (item.show === 'percent') {
+              val = value + '%'
+            } else if (item.show === 'thdSeparator') {
+              val = val + ''
+              val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
             }
 
-            if (item.show === 'percent') {
-              value = value + '%'
-            }
             return {
-              content: value,
+              content: val,
               style: {
                 fill: plot.color
               }
@@ -1617,13 +1759,14 @@
     }
     if (plot.max || plot.max === 0) {
       c.max = plot.max
+      c.min = c.min || 0
     }
     chart.scale(_valfield, c)
 
     chart.axis(plot.Xaxis, plot.$xc)
     chart.axis(_valfield, plot.$yc)
 
-    if (!plot.legend || plot.legend === 'hidden') {
+    if (!plot.legend) {
       chart.legend(false)
     } else {
       chart.legend({
@@ -1700,9 +1843,16 @@
         ])
         .shape(plot.shape || 'rect')
         .tooltip(`${plot.Xaxis}*${_valfield}*${_typefield}`, (name, value, type) => {
+          let val = value
+          if (plot.show === 'percent') {
+            val = value + '%'
+          } else if (plot.show === 'thdSeparator') {
+            val = val + ''
+            val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
+          }
           return {
             name: type,
-            value: plot.show === 'percent' ? value + '%' : value
+            value: val
           }
         })
 
@@ -1735,12 +1885,16 @@
       }
       if (plot.label !== 'false') {
         _chart.label(`${_valfield}*${_typefield}`, (value, key) => {
-          if (plot.labelValue === 'zero' && value === 0) {
+          if (plot.label !== 'true' && value === 0) {
             return null
           }
 
+          let val = value
           if (plot.show === 'percent') {
-            value = value + '%'
+            val = value + '%'
+          } else if (plot.show === 'thdSeparator') {
+            val = val + ''
+            val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
           }
 
           if (plot.label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) {
@@ -1748,13 +1902,13 @@
           }
 
           return {
-            content: value,
+            content: val,
             ...lablecfg
           }
         })
       }
 
-      if (plot.barSize || plot.correction) {
+      if (plot.barSize) {
         _chart.size(plot.barSize || 35)
       }
       if (plot.selectColor) {
@@ -1776,9 +1930,16 @@
         .adjust('stack')
         .shape(plot.shape || 'rect')
         .tooltip(`${plot.Xaxis}*${_valfield}*${_typefield}`, (name, value, type) => {
+          let val = value
+          if (plot.show === 'percent') {
+            val = value + '%'
+          } else if (plot.show === 'thdSeparator') {
+            val = val + ''
+            val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
+          }
           return {
             name: type,
-            value: plot.show === 'percent' ? value + '%' : value
+            value: val
           }
         })
 
@@ -1810,12 +1971,16 @@
       }
       if (plot.label !== 'false') {
         _chart.label(`${_valfield}*${_typefield}`, (value, key) => {
-          if (plot.labelValue === 'zero' && value === 0) {
+          if (plot.label !== 'true' && value === 0) {
             return null
           }
 
+          let val = value
           if (plot.show === 'percent') {
-            value = value + '%'
+            val = value + '%'
+          } else if (plot.show === 'thdSeparator') {
+            val = val + ''
+            val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
           }
 
           if (plot.label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) {
@@ -1823,13 +1988,13 @@
           }
 
           return {
-            content: value,
+            content: val,
             ...lablecfg
           }
         })
       }
 
-      if (plot.barSize || plot.correction) {
+      if (plot.barSize) {
         _chart.size(plot.barSize || 35)
       }
       if (plot.selectColor) {

--
Gitblit v1.8.0