From 000ff61dd8a88eb875048e6a3deca8679d75df18 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 29 八月 2020 11:29:33 +0800 Subject: [PATCH] 2020-08-29 --- src/menu/components/chart/antv-bar/index.jsx | 53 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/menu/components/chart/antv-bar/index.jsx b/src/menu/components/chart/antv-bar/index.jsx index 4d2f9fa..76cdec7 100644 --- a/src/menu/components/chart/antv-bar/index.jsx +++ b/src/menu/components/chart/antv-bar/index.jsx @@ -31,13 +31,14 @@ } UNSAFE_componentWillMount () { - const { card } = this.props + const { card, config } = this.props if (card.isNew) { let _plot = { chartType: card.type, // 鍥捐〃绫诲瀷 enabled: 'false', // 鏄惁浣跨敤鑷畾涔夎缃� datatype: 'query', // 鏁版嵁绫诲瀷鏌ヨ鎴栫粺璁� + customs: [] } if (card.subtype === 'bar') { @@ -46,13 +47,32 @@ } else if (card.subtype === 'bar1') { _plot.coordinate = 'angle' _plot.transpose = 'true' + } else if (card.subtype === 'line') { + _plot.shape = 'smooth' + } else if (card.subtype === 'line1') { + _plot.shape = 'hv' + } + + let name = '' + let names = { + bar: '鏌辩姸鍥�', + line: '鎶樼嚎鍥�', + } + let i = 1 + + while (!name) { + let _name = names[card.type] + i + if (config.components.filter(com => com.setting && com.setting.name === _name).length === 0) { + name = _name + } + i++ } let _card = { uuid: card.uuid, type: card.type, subtype: card.subtype, - setting: {span: 12, height: 400}, + setting: {span: 12, height: 400, name}, columns: [], scripts: [], search: [], @@ -76,9 +96,7 @@ UNSAFE_componentWillReceiveProps (nextProps) { if (!is(fromJS(this.props.plot), fromJS(nextProps.plot))) { - this.setState({}, () => { - this.viewrender() - }) + } } @@ -117,10 +135,11 @@ } linerender = () => { - const { plot, config } = this.props + const { card } = this.state + let plot = {...card.plot, height: card.setting.height - 70} let transfield = {} - config.columns.forEach(col => { + card.columns.forEach(col => { if (col.field) { transfield[col.field] = col.label } @@ -153,7 +172,7 @@ } const chart = new Chart({ - container: plot.uuid, + container: card.uuid, autoFit: true, height: plot.height || 400 }) @@ -509,8 +528,24 @@ } updateComponent = (component) => { + const card = fromJS(this.state.card).toJS() + let refresh = false + if (card.setting.span !== component.setting.span || card.setting.height !== component.setting.height || !is(fromJS(component.plot), fromJS(card.plot))) { + let _element = document.getElementById(card.uuid) + if (_element) { + _element.innerHTML = '' + } + refresh = true + } + this.setState({ card: component + }, () => { + if (refresh) { + setTimeout(() => { + this.viewrender() + }, 100) + } }) this.props.updateConfig(component) } @@ -520,7 +555,7 @@ const { config } = this.props return ( - <div className="line-chart-edit-box" style={{height: card.setting.height || 400}}> + <div className="menu-line-chart-edit-box" style={{height: card.setting.height || 400}}> <SettingComponent config={{...card, tables: config.tables}} MenuID={config.uuid} -- Gitblit v1.8.0