| | |
| | | if (item.chartType === 'table') { |
| | | return ( |
| | | <Col span={item.width || 24} key={item.uuid}> |
| | | {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} |
| | | {config.charts.length > 1 && item.title ? <p className="chart-table chart-title">{item.title}</p> : null} |
| | | <div style={{minHeight: '25px'}}> |
| | | <MainAction |
| | | BID="" |
| | |
| | | .chart-title { |
| | | position: relative; |
| | | top: -20px; |
| | | margin-bottom: 0px; |
| | | color: rgba(0, 0, 0, 0.85); |
| | | font-weight: 400; |
| | | font-size: 16px; |
| | | line-height: 25px; |
| | | height: 35px; |
| | | text-overflow: ellipsis; |
| | | white-space: nowrap; |
| | | overflow: hidden; |
| | | max-width: 50%; |
| | | padding-top: 10px; |
| | | padding-left: 30px; |
| | | margin: 0 20px; |
| | | padding: 10px 5px 5px; |
| | | border-bottom: 1px solid #e8e8e8; |
| | | } |
| | | .chart-table.chart-title { |
| | | position: absolute; |
| | |
| | | } |
| | | |
| | | getdata = () => { |
| | | const { data } = this.props |
| | | // let _data = [] |
| | | 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)) |
| | | |
| | | return data || [] |
| | | if (!data) return [] |
| | | |
| | | let _data = [] |
| | | let _cdata = fromJS(data).toJS() |
| | | |
| | | if (plot.repeat === 'average') { |
| | | let _mdata = new Map() |
| | | _cdata.forEach(item => { |
| | | _columns.forEach(col => { |
| | | if (typeof(item[col.field]) !== 'number') { |
| | | item[col.field] = parseFloat(item[col.field]) |
| | | if (isNaN(item[col.field])) { |
| | | item[col.field] = 0 |
| | | } |
| | | } |
| | | if (col.format === 'percent') { |
| | | item[col.field] = item[col.field] * 100 |
| | | } |
| | | }) |
| | | |
| | | if (item[plot.Xaxis] && !_mdata.has(item[plot.Xaxis])) { |
| | | item.$count = 1 |
| | | _mdata.set(item[plot.Xaxis], item) |
| | | } else if (item[plot.Xaxis]) { |
| | | let _item = _mdata.get(item[plot.Xaxis]) |
| | | _item.$count++ |
| | | vFields.forEach(field => { |
| | | _item[field] += item[field] |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | _data = [..._mdata.values()] |
| | | _data = _data.map(item => { |
| | | _columns.forEach(col => { |
| | | item[col.field] = item[col.field] / item.$count |
| | | item[col.field] = item[col.field].toFixed(col.decimal) |
| | | item[col.field] = +item[col.field] |
| | | }) |
| | | return item |
| | | }) |
| | | } else if (plot.repeat === 'cumsum') { |
| | | let _mdata = new Map() |
| | | _cdata.forEach(item => { |
| | | _columns.forEach(col => { |
| | | if (typeof(item[col.field]) !== 'number') { |
| | | item[col.field] = parseFloat(item[col.field]) |
| | | if (isNaN(item[col.field])) { |
| | | item[col.field] = 0 |
| | | } |
| | | } |
| | | if (col.format === 'percent') { |
| | | item[col.field] = item[col.field] * 100 |
| | | } |
| | | }) |
| | | |
| | | if (item[plot.Xaxis] && !_mdata.has(item[plot.Xaxis])) { |
| | | _mdata.set(item[plot.Xaxis], item) |
| | | } else if (item[plot.Xaxis]) { |
| | | let _item = _mdata.get(item[plot.Xaxis]) |
| | | vFields.forEach(field => { |
| | | _item[field] += item[field] |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | _data = [..._mdata.values()] |
| | | _data = _data.map(item => { |
| | | _columns.forEach(col => { |
| | | item[col.field] = item[col.field].toFixed(col.decimal) |
| | | item[col.field] = +item[col.field] |
| | | }) |
| | | return item |
| | | }) |
| | | } else { // plot.repeat === 'unrepeat' |
| | | let _mdata = new Map() |
| | | _cdata.forEach(item => { |
| | | if (item[plot.Xaxis] && !_mdata.has(item[plot.Xaxis])) { |
| | | _columns.forEach(col => { |
| | | if (typeof(item[col.field]) !== 'number') { |
| | | item[col.field] = parseFloat(item[col.field]) |
| | | if (isNaN(item[col.field])) { |
| | | item[col.field] = 0 |
| | | } |
| | | } |
| | | if (col.format === 'percent') { |
| | | item[col.field] = item[col.field] * 100 |
| | | } |
| | | item[col.field] = item[col.field].toFixed(col.decimal) |
| | | item[col.field] = +item[col.field] |
| | | }) |
| | | _mdata.set(item[plot.Xaxis], item) |
| | | } |
| | | }) |
| | | |
| | | _data = [..._mdata.values()] |
| | | } |
| | | |
| | | return _data |
| | | } |
| | | |
| | | viewrender = () => { |
| | |
| | | |
| | | let data = this.getdata() |
| | | |
| | | if (data.length === 0) { |
| | | return |
| | | } |
| | | |
| | | const ds = new DataSet() |
| | | const dv = ds.createView().source(data) |
| | | |
| | |
| | | |
| | | return ( |
| | | <div className="line-chart-edit-box" style={{minHeight: plot.height ? plot.height + 50 : 450}}> |
| | | <p className="chart-title">{plot.title}</p> |
| | | {plot.title ? <p className="chart-title">{plot.title}</p> : null} |
| | | <div className="canvas" id={plot.uuid}></div> |
| | | </div> |
| | | ) |
| | |
| | | if (item.chartType === 'table') { |
| | | return ( |
| | | <Col span={item.width || 24} key={item.uuid}> |
| | | {config.charts.length > 1 ? <p className="chart-title">{item.title}</p> : null} |
| | | {config.charts.length > 1 && item.title ? <p className="chart-title">{item.title}</p> : null} |
| | | <ActionComponent |
| | | type="main" |
| | | menu={{ MenuID: this.props.menu.MenuID, MenuName: this.props.menu.MenuName, MenuNo: this.props.menu.MenuNo }} |
| | |
| | | margin-bottom: 70px; |
| | | |
| | | .chart-title { |
| | | margin-bottom: 15px; |
| | | position: relative; |
| | | // top: -20px; |
| | | color: rgba(0, 0, 0, 0.85); |
| | | font-weight: 400; |
| | | font-size: 16px; |
| | | line-height: 25px; |
| | | height: 35px; |
| | | text-overflow: ellipsis; |
| | | white-space: nowrap; |
| | | overflow: hidden; |
| | | max-width: 50%; |
| | | padding-top: 10px; |
| | | padding-left: 30px; |
| | | margin: 0 20px; |
| | | padding: 10px 5px 5px; |
| | | border-bottom: 1px solid #e8e8e8; |
| | | |
| | | // margin-bottom: 15px; |
| | | // color: rgba(0, 0, 0, 0.85); |
| | | // font-weight: 400; |
| | | // font-size: 16px; |
| | | // line-height: 25px; |
| | | // height: 35px; |
| | | // text-overflow: ellipsis; |
| | | // white-space: nowrap; |
| | | // overflow: hidden; |
| | | // max-width: 50%; |
| | | // padding-top: 10px; |
| | | // padding-left: 30px; |
| | | } |
| | | } |
| | | } |
| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | // import { is, fromJS } from 'immutable' |
| | | import { fromJS } from 'immutable' |
| | | import { Drawer, Form, Button, Col, Row, Select, Icon, Radio, Tooltip, Input, InputNumber } from 'antd' |
| | | |
| | | import { getChartOptionForm } from '@/templates/zshare/formconfig' |
| | |
| | | } |
| | | |
| | | state = { |
| | | view: 'normal', |
| | | visible: false, |
| | | plot: null, |
| | | formlist: null |
| | | } |
| | | |
| | |
| | | |
| | | this.setState({ |
| | | visible: true, |
| | | plot: fromJS(plot).toJS(), |
| | | formlist: getChartOptionForm(plot, config.columns, config.setting) |
| | | }) |
| | | } |
| | | |
| | | onClose = (type) => { |
| | | if (type !== 'submit') { |
| | | this.setState({ |
| | | visible: false |
| | | }) |
| | | return |
| | | } |
| | | |
| | | onSubmit = () => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | this.setState({ |
| | |
| | | return fields |
| | | } |
| | | |
| | | changeView = () => { |
| | | let _view = this.state.view === 'normal' ? 'custom' : 'normal' |
| | | |
| | | if (_view === 'custom') { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | let _plot = {...this.state.plot, ...values} |
| | | |
| | | this.setState({ |
| | | plot: _plot, |
| | | view: _view |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | this.setState({view: _view}) |
| | | } |
| | | |
| | | render() { |
| | | const { view } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | title="图表编辑" |
| | | className="chart-drawer-form" |
| | | width={720} |
| | | onClose={this.onClose} |
| | | onClose={() => this.setState({ visible: false })} |
| | | visible={this.state.visible} |
| | | bodyStyle={{ paddingBottom: 80 }} |
| | | > |
| | | <Form {...formItemLayout}> |
| | | {view !== 'custom' ? <Form {...formItemLayout}> |
| | | <Row gutter={16}>{this.getFields()}</Row> |
| | | </Form> |
| | | <Row gutter={16}> |
| | | <Button onClick={this.changeView} style={{border: 0, boxShadow: 'unset',float: 'right', color: '#1890ff', marginRight: 12, cursor: 'pointer'}}>自定义设置<Icon style={{marginLeft: 5}} type="right" /></Button> |
| | | </Row> |
| | | </Form> : null} |
| | | {/* <Form {...formItemLayout}> |
| | | <Row gutter={16}> |
| | | <Button onClick={this.changeView} style={{border: 0, boxShadow: 'unset',float: 'right', color: '#1890ff', marginRight: 12, cursor: 'pointer'}}>自定义设置<Icon style={{marginLeft: 5}} type="right" /></Button> |
| | | </Row> |
| | | </Form> */} |
| | | <div |
| | | style={{ |
| | | position: 'absolute', |
| | |
| | | textAlign: 'right', |
| | | }} |
| | | > |
| | | <Button onClick={this.onClose} style={{ marginRight: 8 }}> |
| | | <Button onClick={() => this.setState({ visible: false })} style={{ marginRight: 8 }}> |
| | | 取消 |
| | | </Button> |
| | | <Button onClick={() => this.onClose('submit')} type="primary"> |
| | | <Button onClick={() => this.onSubmit()} type="primary"> |
| | | 提交 |
| | | </Button> |
| | | </div> |
| | |
| | | |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import ChartDrawerForm from './chartcompile' |
| | | import ChartCompileForm from './chartcompile' |
| | | import './index.scss' |
| | | |
| | | class LineChart extends Component { |
| | |
| | | |
| | | return ( |
| | | <div className="line-chart-edit-box" style={{minHeight: plot.height ? plot.height + 50 : 450}}> |
| | | <p className="chart-title">{plot.title}</p> |
| | | {plot.title ? <p className="chart-title">{plot.title}</p> : null} |
| | | <div className="canvas" id={plot.uuid}></div> |
| | | <ChartDrawerForm |
| | | <ChartCompileForm |
| | | plot={plot} |
| | | type={plot.chartType} |
| | | config={this.props.config} |
| | |
| | | param.Ltexttableparam.unshift(`select 'BID' as searchfield,'BID' as label,'0' as Sort,'nvarchar(50)' as fieldtype,'required' as requiredtype,'' as defaultvalue`) |
| | | } |
| | | |
| | | if (btn.Ot !== 'notRequired' && !_keys.includes(config.setting.primaryKey.toLowerCase())) { |
| | | param.Ltexttableparam.unshift(`select '${config.setting.primaryKey}' as searchfield,'${config.setting.primaryKey}' as label,'1' as Sort,'nvarchar(50)' as fieldtype,'required' as requiredtype,'' as defaultvalue`) |
| | | if (btn.Ot !== 'notRequired' && !_keys.includes('id')) { |
| | | param.Ltexttableparam.unshift(`select 'ID' as searchfield,'ID' as label,'1' as Sort,'nvarchar(50)' as fieldtype,'required' as requiredtype,'' as defaultvalue`) |
| | | } |
| | | |
| | | param.Ltexttableparam = param.Ltexttableparam.join(' union all ') |
| | |
| | | }, { |
| | | value: 'thdSeparator', |
| | | text: Formdict['header.form.thdSeparator'] |
| | | }, { |
| | | value: 'percent', |
| | | text: '百分比' |
| | | }], |
| | | required: false |
| | | }, |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 组件销毁,清除state更新 |
| | | */ |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | } |
| | | |
| | | render () { |
| | | const { lineColor, bgImage, loginlogo, copyRight, webSite, ICP } = this.state |
| | | |