From 4453a9e63e8e176c70c432b03fd4ba3ebf00a04c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 09 二月 2023 14:55:20 +0800
Subject: [PATCH] 2023-02-09

---
 src/tabviews/custom/components/chart/antv-bar-line/index.jsx |   70 +++++++++++++++++++++++++++--------
 1 files changed, 54 insertions(+), 16 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 5bc343a..dc80392 100644
--- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
+++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
@@ -1478,6 +1478,7 @@
     let _valfield = 'value'
     let _typefield = 'key'
     let colorIndex = 0
+    let barcolors = {}
 
     if (plot.datatype === 'statistics') {
       _valfield = plot.InfoValue
@@ -1490,6 +1491,16 @@
       if (plot.enabled === 'true') {
         this.customrender(data)
         return
+      }
+
+      if (plot.barcolors && plot.barcolors.length > 0 && plot.Yaxis.length === 1) {
+        data.forEach((item, i) => {
+          if (plot.barcolors[i]) {
+            barcolors[item[plot.Xaxis]] = plot.barcolors[i].color
+          }
+        })
+      } else {
+        barcolors = null
       }
 
       const ds = new DataSet()
@@ -1624,14 +1635,28 @@
 
       if (plot.$colors) {
         let limit = chartColors.length
-        _chart.color(_typefield, (key) => {
-          if (plot.$colors.has(key)) {
-            return plot.$colors.get(key)
-          } else {
-            colorIndex++
-            return chartColors[(colorIndex - 1) % limit]
-          }
-        })
+
+        if (barcolors) {
+          _chart.color(`${_typefield}*${plot.Xaxis}`, (key, label) => {
+            if (barcolors[label]) {
+              return barcolors[label]
+            } else if (plot.$colors.has(key)) {
+              return plot.$colors.get(key)
+            } else {
+              colorIndex++
+              return chartColors[(colorIndex - 1) % limit]
+            }
+          })
+        } else {
+          _chart.color(`${_typefield}`, (key) => {
+            if (plot.$colors.has(key)) {
+              return plot.$colors.get(key)
+            } else {
+              colorIndex++
+              return chartColors[(colorIndex - 1) % limit]
+            }
+          })
+        }
       } else {
         _chart.color(_typefield)
       }
@@ -1686,14 +1711,27 @@
 
       if (plot.$colors) {
         let limit = chartColors.length
-        _chart.color(_typefield, (key) => {
-          if (plot.$colors.has(key)) {
-            return plot.$colors.get(key)
-          } else {
-            colorIndex++
-            return chartColors[(colorIndex - 1) % limit]
-          }
-        })
+        if (barcolors) {
+          _chart.color(`${_typefield}*${plot.Xaxis}`, (key, label) => {
+            if (barcolors[label]) {
+              return barcolors[label]
+            } else if (plot.$colors.has(key)) {
+              return plot.$colors.get(key)
+            } else {
+              colorIndex++
+              return chartColors[(colorIndex - 1) % limit]
+            }
+          })
+        } else {
+          _chart.color(`${_typefield}`, (key) => {
+            if (plot.$colors.has(key)) {
+              return plot.$colors.get(key)
+            } else {
+              colorIndex++
+              return chartColors[(colorIndex - 1) % limit]
+            }
+          })
+        }
       } else {
         _chart.color(_typefield)
       }

--
Gitblit v1.8.0