From f393af9623c26ae177a3f69b8676afc4e23bff8d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 08 二月 2022 14:48:51 +0800 Subject: [PATCH] 2022-02-08 --- src/menu/components/chart/antv-scatter/index.jsx | 72 +++++++++++++++++++++--------------- 1 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/menu/components/chart/antv-scatter/index.jsx b/src/menu/components/chart/antv-scatter/index.jsx index e948102..e8b381e 100644 --- a/src/menu/components/chart/antv-scatter/index.jsx +++ b/src/menu/components/chart/antv-scatter/index.jsx @@ -1,7 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Icon, Popover, notification } from 'antd' +import { Popover, notification } from 'antd' +import { ToolOutlined, DeleteOutlined, FontColorsOutlined, PlusCircleOutlined, PlusSquareOutlined } from '@ant-design/icons' import { Chart } from '@antv/g2' import MKEmitter from '@/utils/events.js' @@ -33,7 +34,7 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, card: null, - ismob: sessionStorage.getItem('appType') === 'mob', + appType: sessionStorage.getItem('appType'), eventListener: null } @@ -57,7 +58,6 @@ let _card = { uuid: card.uuid, type: card.type, - floor: card.floor, tabId: card.tabId || '', parentId: card.parentId || '', format: 'array', // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡 @@ -89,6 +89,10 @@ _card.style = config.style _card.headerStyle = config.headerStyle + _card.setting = config.setting + _card.columns = config.columns + _card.scripts = config.scripts + _card.action = config.action.map(col => { col.uuid = Utils.getuuid() return col @@ -110,9 +114,11 @@ } componentDidMount () { - this.ponitrender() MKEmitter.addListener('submitStyle', this.getStyle) MKEmitter.addListener('tabsChange', this.handleTabsChange) + setTimeout(() => { + this.ponitrender() + }, 1000) } shouldComponentUpdate (nextProps, nextState) { @@ -189,7 +195,7 @@ const chart = new Chart({ container: card.uuid + 'canvas', autoFit: true, - height: plot.height - 70 + height: this.wrap.offsetHeight - 25 }) chart.data(data); @@ -207,13 +213,18 @@ itemName: { style: { fill: plot.color } } }) - chart.tooltip({ - showTitle: false, - showCrosshairs: true, - crosshairs: { - type: 'xy', - } - }) + if (plot.tooltip !== 'true') { + chart.tooltip(false) + } else { + chart.tooltip({ + showTitle: false, + showCrosshairs: true, + crosshairs: { + type: 'xy', + } + }) + } + chart .point() .position('height*weight') @@ -228,14 +239,18 @@ .style({ fillOpacity: 0.85 }) - chart.interaction('legend-highlight'); + if (plot.interaction && plot.interaction.length) { + plot.interaction.forEach(t => { + chart.interaction(t) + }) + } chart.render() } updateComponent = (component) => { const card = fromJS(this.state.card).toJS() - if (!is(fromJS(component.plot), fromJS(card.plot)) || !is(fromJS(component.style), fromJS(card.style))) { + if (!is(fromJS(component.plot), fromJS(card.plot)) || !is(fromJS(component.style), fromJS(card.style)) || !is(fromJS(component.search), fromJS(card.search))) { let _element = document.getElementById(card.uuid + 'canvas') if (_element) { _element.innerHTML = '' @@ -267,9 +282,7 @@ newcard.type = 'select' newcard.resourceType = '0' newcard.options = [] - newcard.setAll = 'false' newcard.orderType = 'asc' - newcard.display = 'dropdown' newcard.match = '=' // 娉ㄥ唽浜嬩欢-娣诲姞鎼滅储 @@ -297,7 +310,6 @@ newcard.execSuccess = 'grid' newcard.execError = 'never' newcard.popClose = 'never' - newcard.errorTime = 10 newcard.verify = null newcard.show = 'icon' @@ -308,7 +320,7 @@ changeStyle = () => { const { card } = this.state - MKEmitter.emit('changeStyle', [card.uuid], ['background', 'border', 'padding', 'margin'], card.style) + MKEmitter.emit('changeStyle', [card.uuid], ['background', 'border', 'padding', 'margin', 'shadow'], card.style) } getStyle = (comIds, style) => { @@ -355,31 +367,31 @@ } render() { - const { card, ismob } = this.state + const { card, appType } = this.state let _style = resetStyle(card.style) return ( - <div className="menu-line-chart-edit-box" style={{..._style, height: card.plot.height || 400}} onClick={this.clickComponent} id={card.uuid}> - <NormalHeader config={card} updateComponent={this.updateComponent}/> + <div className="menu-scatter-chart-edit-box" style={{..._style, height: card.plot.height || 400}} onClick={this.clickComponent} id={card.uuid}> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> - {!ismob ? <Icon className="plus" title="娣诲姞鎼滅储" onClick={this.addSearch} type="plus-circle" /> : null} - <Icon className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} type="plus-square" /> + {appType !== 'mob' ? <PlusCircleOutlined className="plus" title="娣诲姞鎼滅储" onClick={this.addSearch}/> : null} + {appType !== 'mob' ? <PlusSquareOutlined className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton}/> : null} <ChartCompileForm config={card} dict={this.state.dict} plotchange={this.updateComponent}/> <CopyComponent type="line" card={card}/> - <PasteComponent config={card} options={['action', 'search', 'form']} updateConfig={this.updateComponent} /> - <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" /> - <LogComponent btnlog={card.btnlog || []} handlelog={this.handleLog} /> + <PasteComponent config={card} options={['action']} updateConfig={this.updateComponent}/> + <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/> + <LogComponent btnlog={card.btnlog || []} handlelog={this.handleLog}/> <ClockComponent config={card} updateConfig={this.updateComponent}/> <UserComponent config={card}/> - <Icon className="close" title="delete" type="delete" onClick={() => this.props.deletecomponent(card.uuid)} /> + <DeleteOutlined className="close" title="delete" onClick={() => this.props.deletecomponent(card.uuid)}/> <SettingComponent config={card} updateConfig={this.updateComponent}/> </div> } trigger="hover"> - <Icon type="tool" /> + <ToolOutlined/> </Popover> - <ActionComponent type="chart" config={card} updateaction={this.updateComponent} /> - <div className="canvas" id={card.uuid + 'canvas'}></div> + <NormalHeader config={card} updateComponent={this.updateComponent}/> + <div className="canvas" id={card.uuid + 'canvas'} ref={ref => this.wrap = ref}></div> + {appType !== 'mob' ? <ActionComponent type="chart" config={card} updateaction={this.updateComponent}/> : null} </div> ) } -- Gitblit v1.8.0