From 7090326d3b7faa8122df3808832745e6fdda749b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 06 二月 2023 19:30:51 +0800
Subject: [PATCH] 2023-02-06

---
 src/tabviews/custom/components/chart/antv-bar-line/index.jsx |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 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..70caf6f 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,14 @@
       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
+          }
+        })
       }
 
       const ds = new DataSet()
@@ -1624,8 +1633,10 @@
 
       if (plot.$colors) {
         let limit = chartColors.length
-        _chart.color(_typefield, (key) => {
-          if (plot.$colors.has(key)) {
+        _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++
@@ -1686,8 +1697,10 @@
 
       if (plot.$colors) {
         let limit = chartColors.length
-        _chart.color(_typefield, (key) => {
-          if (plot.$colors.has(key)) {
+        _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++

--
Gitblit v1.8.0