| | |
| | | import DataSet from '@antv/data-set' |
| | | import { Spin, Empty, Select } from 'antd' |
| | | |
| | | import asyncComponent from './asyncButtonComponent' |
| | | import Utils from '@/utils/utils.js' |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import './index.scss' |
| | | |
| | | const ExcelOutButton = asyncComponent(() => import('@/tabviews/zshare/actionList/exceloutbutton')) |
| | | const ExcelInButton = asyncComponent(() => import('@/tabviews/zshare/actionList/excelInbutton')) |
| | | |
| | | class LineChart extends Component { |
| | | static propTpyes = { |
| | | BID: PropTypes.any, |
| | | Tab: PropTypes.any, |
| | | plot: PropTypes.object, |
| | | data: PropTypes.array, |
| | | loading: PropTypes.bool, |
| | | config: PropTypes.object |
| | | config: PropTypes.object, |
| | | getexceloutparam: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | empty: true, |
| | | actions: [], |
| | | chartId: Utils.getuuid(), |
| | | chartData: [], |
| | | chartFields: [], |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | const { plot, data } = this.props |
| | | |
| | | const { plot, data, config } = this.props |
| | | let _state = {} |
| | | let actions = [] |
| | | config.action.forEach(item => { |
| | | if (!plot.actions || plot.actions.length === 0) return |
| | | if (!(item.OpenType === 'excelOut' || (item.OpenType === 'excelIn' && item.Ot === 'notRequired'))) return |
| | | if (plot.actions.includes(item.uuid)) { |
| | | actions.push(fromJS(item).toJS()) |
| | | } |
| | | }) |
| | | |
| | | if (plot.datatype === 'statistics' && (plot.chartType === 'line' || plot.chartType === 'bar')) { |
| | | let result = this.getStaticMsg(data) |
| | | _state.chartData = result.data |
| | | _state.chartFields = result.chartFields |
| | | _state.selectFields = result.selectFields |
| | | _state.actions = actions |
| | | |
| | | this.setState(_state, () => { |
| | | this.viewrender() |
| | | }) |
| | | } else { |
| | | this.setState({ actions }) |
| | | this.viewrender() |
| | | } |
| | | } |
| | |
| | | |
| | | getdata = () => { |
| | | const { data, plot, config } = this.props |
| | | |
| | | let vFields = plot.Yaxis && typeof(plot.Yaxis) === 'string' ? [plot.Yaxis] : plot.Yaxis |
| | | let _columns = config.columns.filter(col => vFields.includes(col.field)) |
| | | |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { plot, loading } = this.props |
| | | const { empty, chartFields, selectFields } = this.state |
| | | const { plot, loading, config, BID, Tab } = this.props |
| | | const { empty, chartFields, selectFields, actions } = this.state |
| | | |
| | | return ( |
| | | <div className="line-chart-plot-box"> |
| | |
| | | > |
| | | {chartFields.map((item, i) => <Select.Option key={i} value={item}>{item}</Select.Option>)} |
| | | </Select> : null} |
| | | <div className="canvas-wrap"> |
| | | <div className={'chart-action ' + (plot.title ? 'with-title' : '')}> |
| | | {actions.map(item => { |
| | | if (item.OpenType === 'excelOut') { |
| | | return ( |
| | | <ExcelOutButton |
| | | key={item.uuid} |
| | | BID={BID} |
| | | Tab={Tab} |
| | | btn={item} |
| | | show="icon" |
| | | setting={config.setting} |
| | | getexceloutparam={this.props.getexceloutparam} |
| | | updateStatus={() => {}} |
| | | /> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <ExcelInButton |
| | | key={item.uuid} |
| | | BID={BID} |
| | | Tab={Tab} |
| | | btn={item} |
| | | show="icon" |
| | | setting={config.setting} |
| | | updateStatus={() => {}} |
| | | /> |
| | | ) |
| | | } |
| | | })} |
| | | </div> |
| | | <div className={'canvas' + (empty ? ' empty' : '')} style={{minHeight: plot.height ? plot.height : 400}} id={this.state.chartId}></div> |
| | | </div> |
| | | {empty ? <Empty description={false}/> : null} |
| | | </div> |
| | | ) |