From 8d66ff34fae5b048a6b7923cc75d34f13a08be9d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 02 八月 2022 11:42:43 +0800 Subject: [PATCH] Merge branch 'develop' --- src/menu/components/chart/antv-bar/chartcompile/index.jsx | 92 +++++++++++++++++++++++++++++++++++---------- 1 files changed, 71 insertions(+), 21 deletions(-) diff --git a/src/menu/components/chart/antv-bar/chartcompile/index.jsx b/src/menu/components/chart/antv-bar/chartcompile/index.jsx index accb869..61f053f 100644 --- a/src/menu/components/chart/antv-bar/chartcompile/index.jsx +++ b/src/menu/components/chart/antv-bar/chartcompile/index.jsx @@ -286,7 +286,7 @@ if (key === 'datatype') { this.setState({ datatype: val, - formlist: formlist.map(item => { + formlist: fromJS(formlist).toJS().map(item => { if (['Yaxis'].includes(item.key)) { item.hidden = val === 'statistics' } else if (['InfoType', 'InfoValue'].includes(item.key)) { @@ -295,6 +295,26 @@ return item }) }) + } else if (key === 'label') { + this.setState({formlist: fromJS(formlist).toJS().map(cell => { + if (!['labelColor', 'labelValue'].includes(cell.key)) return cell + + if (cell.key === 'labelColor') { + if (val !== 'true') { + cell.hidden = true + } else { + cell.hidden = false + } + } else { + if (val === 'false') { + cell.hidden = true + } else { + cell.hidden = false + } + } + + return cell + })}) } } @@ -477,17 +497,39 @@ if (!err) { let _plot = {...plot, ...values} - if (values.datatype === 'statistics' || values.datatype !== plot.datatype) { - _plot.enabled = 'false' - _plot.customs = [] - } else if (!values.Yaxis || !plot.Yaxis || !is(fromJS(values.Yaxis), fromJS(plot.Yaxis))) { - _plot.enabled = 'false' - _plot.customs = [] - _plot.colors = null - } - if (values.datatype !== plot.datatype) { _plot.colors = null + } + if (values.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 + + 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'] + } + }) } this.setState({ @@ -560,22 +602,29 @@ if (!err) { let _plot = {...plot, ...values} - if (values.datatype === 'statistics' || values.datatype !== plot.datatype) { - _plot.enabled = 'false' - _plot.customs = [] - } else if (!values.Yaxis || !plot.Yaxis || !is(fromJS(values.Yaxis), fromJS(plot.Yaxis))) { - _plot.enabled = 'false' - _plot.customs = [] - _plot.colors = null - } - let labels = {} config.columns.forEach(col => { labels[col.field] = col.label }) - if (values.datatype !== 'statistics' && (!_plot.customs || _plot.customs.length === 0)) { + if (values.datatype !== plot.datatype) { + _plot.colors = null + } + if (values.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 + + 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, @@ -587,7 +636,8 @@ } }) } - if (values.datatype !== plot.datatype || !_plot.colors) { + + if (!_plot.colors) { _plot.colors = [] if (_plot.datatype === 'query') { let limit = chartColors.length -- Gitblit v1.8.0