From 1b6086e0fb66410fb237e6893f791a26bf2e7ff1 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 22 十一月 2023 10:37:00 +0800 Subject: [PATCH] 2023-11-22 --- src/menu/components/chart/antv-bar/chartcompile/index.jsx | 78 +++++++++++++++++++++++---------------- 1 files changed, 46 insertions(+), 32 deletions(-) diff --git a/src/menu/components/chart/antv-bar/chartcompile/index.jsx b/src/menu/components/chart/antv-bar/chartcompile/index.jsx index b6ddf6e..9faa0e8 100644 --- a/src/menu/components/chart/antv-bar/chartcompile/index.jsx +++ b/src/menu/components/chart/antv-bar/chartcompile/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' +import { fromJS } from 'immutable' import { Modal, Form, Row, Col, Select, Radio, notification, Tooltip, Input, InputNumber, Tabs, Button } from 'antd' import { QuestionCircleOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons' @@ -566,17 +566,14 @@ if (!err) { let _plot = {...plot, ...values} - if (values.datatype !== plot.datatype) { + if (_plot.datatype !== plot.datatype) { _plot.colors = null } - if (values.datatype === 'statistics') { + if (_plot.datatype === 'statistics') { _plot.enabled = 'false' _plot.customs = [] delete _plot.Yaxis - } else if (!is(fromJS(values.Yaxis), fromJS(plot.Yaxis || []))) { - // _plot.enabled = 'false' - // _plot.colors = null - + } else if (_plot.Yaxis) { let labels = {} config.columns.forEach(col => { labels[col.field] = col.label @@ -597,6 +594,24 @@ 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] } }) } @@ -671,21 +686,19 @@ if (!err) { let _plot = {...plot, ...values} - let labels = {} - config.columns.forEach(col => { - labels[col.field] = col.label - }) - - if (values.datatype !== plot.datatype) { + if (_plot.datatype !== plot.datatype) { _plot.colors = null } - if (values.datatype === 'statistics') { + if (_plot.datatype === 'statistics') { _plot.enabled = 'false' _plot.customs = [] + _plot.colors = _plot.colors || [] delete _plot.Yaxis - } else if (!is(fromJS(values.Yaxis), fromJS(plot.Yaxis || []))) { - // _plot.enabled = 'false' - // _plot.colors = null + } else if (_plot.Yaxis) { + let labels = {} + config.columns.forEach(col => { + labels[col.field] = col.label + }) let cus = {} _plot.customs && _plot.customs.forEach(m => { @@ -704,23 +717,24 @@ shape: _plot.chartType === 'bar' && i === 0 ? ['bar', 'rect'] : ['line', 'smooth'] } }) - } - if (!_plot.colors) { - _plot.colors = [] - if (_plot.datatype === 'query') { - let limit = chartColors.length + let cusColor = {} + let limit = chartColors.length - _plot.colors = _plot.Yaxis.map((item, i) => { - return { - uuid: Utils.getuuid(), - type: item, - label: labels[item] || item, - color: chartColors[i % limit], - color1: chartColors[i % limit] - } - }) - } + _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({ -- Gitblit v1.8.0