From 2ac9fde37a97e1ceb6b05aa9e5b0476a396339a9 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 22 十一月 2023 21:59:21 +0800
Subject: [PATCH] 2023-11-22
---
src/menu/components/chart/antv-bar/chartcompile/index.jsx | 170 ++++++++++++++++++++++++++++++--------------------------
src/menu/components/chart/antv-bar/index.jsx | 4 +
2 files changed, 96 insertions(+), 78 deletions(-)
diff --git a/src/menu/components/chart/antv-bar/chartcompile/index.jsx b/src/menu/components/chart/antv-bar/chartcompile/index.jsx
index 1bcb634..ff38788 100644
--- a/src/menu/components/chart/antv-bar/chartcompile/index.jsx
+++ b/src/menu/components/chart/antv-bar/chartcompile/index.jsx
@@ -574,46 +574,53 @@
_plot.customs = []
delete _plot.Yaxis
} else if (_plot.Yaxis) {
- let labels = {}
- config.columns.forEach(col => {
- labels[col.field] = col.label
- })
+ let yaxis = JSON.parse(JSON.stringify(_plot.Yaxis))
+ let caxis = _plot.customs ? _plot.customs.map(m => m.type) : []
+ yaxis.sort()
+ caxis.sort()
+
+ if (JSON.stringify(yaxis) !== JSON.stringify(caxis)) {
+ let labels = {}
+ config.columns.forEach(col => {
+ labels[col.field] = col.label
+ })
+
+ let cus = {}
+ _plot.customs && _plot.customs.forEach(m => {
+ cus[m.type] = m
+ })
+ _plot.customs = _plot.Yaxis.map((item, i) => {
+ if (cus[item]) return cus[item]
+
+ return {
+ uuid: Utils.getuuid(),
+ type: item,
+ name: labels[item] || item,
+ axis: i === 0 ? 'true' : 'false',
+ label: 'false',
+ title: 'true',
+ shape: _plot.chartType === 'bar' && i === 0 ? ['bar', 'rect'] : ['line', 'smooth']
+ }
+ })
- let cus = {}
- _plot.customs && _plot.customs.forEach(m => {
- cus[m.type] = m
- })
- _plot.customs = _plot.Yaxis.map((item, i) => {
- if (cus[item]) return cus[item]
-
- return {
- uuid: Utils.getuuid(),
- type: item,
- name: labels[item] || item,
- axis: i === 0 ? 'true' : 'false',
- label: 'false',
- title: 'true',
- shape: _plot.chartType === 'bar' && i === 0 ? ['bar', 'rect'] : ['line', 'smooth']
- }
- })
-
- let cusColor = {}
- let limit = chartColors.length
-
- _plot.colors && _plot.colors.forEach(m => {
- cusColor[m.type] = m
- })
- _plot.colors = _plot.Yaxis.map((item, i) => {
- if (cusColor[item]) return cusColor[item]
-
- return {
- uuid: Utils.getuuid(),
- type: item,
- label: labels[item] || item,
- color: chartColors[i % limit],
- color1: chartColors[i % limit]
- }
- })
+ let cusColor = {}
+ let limit = chartColors.length
+
+ _plot.colors && _plot.colors.forEach(m => {
+ cusColor[m.type] = m
+ })
+ _plot.colors = _plot.Yaxis.map((item, i) => {
+ if (cusColor[item]) return cusColor[item]
+
+ return {
+ uuid: Utils.getuuid(),
+ type: item,
+ label: labels[item] || item,
+ color: chartColors[i % limit],
+ color1: chartColors[i % limit]
+ }
+ })
+ }
}
this.setState({
@@ -695,46 +702,53 @@
_plot.colors = _plot.colors || []
delete _plot.Yaxis
} else if (_plot.Yaxis) {
- let labels = {}
- config.columns.forEach(col => {
- labels[col.field] = col.label
- })
+ let yaxis = JSON.parse(JSON.stringify(_plot.Yaxis))
+ let caxis = _plot.customs ? _plot.customs.map(m => m.type) : []
+ yaxis.sort()
+ caxis.sort()
- let cus = {}
- _plot.customs && _plot.customs.forEach(m => {
- cus[m.type] = m
- })
- _plot.customs = _plot.Yaxis.map((item, i) => {
- if (cus[item]) return cus[item]
-
- return {
- uuid: Utils.getuuid(),
- type: item,
- name: labels[item] || item,
- axis: i === 0 ? 'true' : 'false',
- label: _plot.label === 'false' ? 'false' : true,
- title: 'true',
- shape: _plot.chartType === 'bar' && i === 0 ? ['bar', 'rect'] : ['line', 'smooth']
- }
- })
-
- let cusColor = {}
- let limit = chartColors.length
-
- _plot.colors && _plot.colors.forEach(m => {
- cusColor[m.type] = m
- })
- _plot.colors = _plot.Yaxis.map((item, i) => {
- if (cusColor[item]) return cusColor[item]
-
- return {
- uuid: Utils.getuuid(),
- type: item,
- label: labels[item] || item,
- color: chartColors[i % limit],
- color1: chartColors[i % limit]
- }
- })
+ if (JSON.stringify(yaxis) !== JSON.stringify(caxis)) {
+ let labels = {}
+ config.columns.forEach(col => {
+ labels[col.field] = col.label
+ })
+
+ let cus = {}
+ _plot.customs && _plot.customs.forEach(m => {
+ cus[m.type] = m
+ })
+ _plot.customs = _plot.Yaxis.map((item, i) => {
+ if (cus[item]) return cus[item]
+
+ return {
+ uuid: Utils.getuuid(),
+ type: item,
+ name: labels[item] || item,
+ axis: i === 0 ? 'true' : 'false',
+ label: _plot.label === 'false' ? 'false' : true,
+ title: 'true',
+ shape: _plot.chartType === 'bar' && i === 0 ? ['bar', 'rect'] : ['line', 'smooth']
+ }
+ })
+
+ let cusColor = {}
+ let limit = chartColors.length
+
+ _plot.colors && _plot.colors.forEach(m => {
+ cusColor[m.type] = m
+ })
+ _plot.colors = _plot.Yaxis.map((item, i) => {
+ if (cusColor[item]) return cusColor[item]
+
+ return {
+ uuid: Utils.getuuid(),
+ type: item,
+ label: labels[item] || item,
+ color: chartColors[i % limit],
+ color1: chartColors[i % limit]
+ }
+ })
+ }
}
this.setState({
diff --git a/src/menu/components/chart/antv-bar/index.jsx b/src/menu/components/chart/antv-bar/index.jsx
index ad77f84..7cca88e 100644
--- a/src/menu/components/chart/antv-bar/index.jsx
+++ b/src/menu/components/chart/antv-bar/index.jsx
@@ -628,6 +628,10 @@
})
const dst = new DataSet()
const dvt = dst.createView().source(data)
+
+ // if (plot.mutilBar === 'stack') {
+ // Bar_axis.reverse()
+ // }
dvt.transform({
type: 'fold',
--
Gitblit v1.8.0