|
|
@@ -1,8 +1,7 @@
|
|
|
import React from 'react'
|
|
|
import { connect } from 'dva'
|
|
|
-import { Input, InputNumber, Form, Checkbox, Select, Tooltip, Divider, Row, Col } from 'antd'
|
|
|
+import { InputNumber, Form, Select, Tooltip, Divider } from 'antd'
|
|
|
import { deepAssign } from '../../../../utils/baseUtils'
|
|
|
-import adapteGridPosition from '../../../../models/adapteGridPosition'
|
|
|
const FormItem = Form.Item;
|
|
|
|
|
|
class ScatterStyle extends React.Component {
|
|
|
@@ -20,131 +19,12 @@ class ScatterStyle extends React.Component {
|
|
|
render() {
|
|
|
const { formItemLayout } = this.state;
|
|
|
const { chartDesigner, dispatch } = this.props;
|
|
|
- const { styleConfig, chartOption, scatterConfig } = chartDesigner;
|
|
|
- const { groupBy } = scatterConfig;
|
|
|
+ const { styleConfig, chartOption } = chartDesigner;
|
|
|
const scatterStyle = styleConfig.scatter || {};
|
|
|
- chartOption.series = chartOption.series || [];
|
|
|
+ chartOption.baseOption = chartOption.baseOption || {};
|
|
|
+ chartOption.baseOption.series = chartOption.baseOption.series || [];
|
|
|
|
|
|
return <Form>
|
|
|
- <Divider>图域</Divider>
|
|
|
- <Form.Item label='位置' {...formItemLayout}>
|
|
|
- <Row>
|
|
|
- <Col span={8}>上边距:</Col>
|
|
|
- <Col span={16}>
|
|
|
- <Input
|
|
|
- key={`scatter-grid-position-top-${scatterStyle.gridPosition ? scatterStyle.gridPosition['top'] : null}`}
|
|
|
- defaultValue={scatterStyle.gridPosition ? scatterStyle.gridPosition['top'] : null}
|
|
|
- placeholder={50}
|
|
|
- onBlur={e => {
|
|
|
- let value = e.target.value;
|
|
|
- let gridPosition = adapteGridPosition({
|
|
|
- legendHidden: !!groupBy && !!groupBy.key ? scatterStyle.legendHidden : true,
|
|
|
- legendOrient: scatterStyle.legendOrient || 'vertical',
|
|
|
- legendLeft: scatterStyle.legendPosition ? scatterStyle.legendPosition.left || 'auto' : 'auto',
|
|
|
- legendRight: scatterStyle.legendPosition ? scatterStyle.legendPosition.right || '5%' : '5%',
|
|
|
- legendTop: scatterStyle.legendPosition ? scatterStyle.legendPosition.top || 50 : 50,
|
|
|
- legendBottom: scatterStyle.legendPosition ? scatterStyle.legendPosition.bottom || 50 : 50,
|
|
|
- });
|
|
|
- dispatch({ type: 'chartDesigner/setFields', fields: [
|
|
|
- { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { gridPosition: { top: value} } }) },
|
|
|
- { name: 'chartOption', value: deepAssign(chartOption, { grid: {
|
|
|
- top: (value && value !== 'auto') ? ( // 已设置图域上边距
|
|
|
- value
|
|
|
- ) : gridPosition.top,
|
|
|
- } }) },
|
|
|
- ] });
|
|
|
- }}
|
|
|
- />
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- <Row>
|
|
|
- <Col span={8}>下边距:</Col>
|
|
|
- <Col span={16}>
|
|
|
- <Input
|
|
|
- key={`scatter-grid-position-bottom-${scatterStyle.gridPosition ? scatterStyle.gridPosition['bottom'] : null}`}
|
|
|
- defaultValue={scatterStyle.gridPosition ? scatterStyle.gridPosition['bottom'] : null}
|
|
|
- placeholder={50}
|
|
|
- onBlur={e => {
|
|
|
- let value = e.target.value;
|
|
|
- let gridPosition = adapteGridPosition({
|
|
|
- legendHidden: !!groupBy && !!groupBy.key ? scatterStyle.legendHidden : true,
|
|
|
- legendOrient: scatterStyle.legendOrient || 'vertical',
|
|
|
- legendLeft: scatterStyle.legendPosition ? scatterStyle.legendPosition.left || 'auto' : 'auto',
|
|
|
- legendRight: scatterStyle.legendPosition ? scatterStyle.legendPosition.right || '5%' : '5%',
|
|
|
- legendTop: scatterStyle.legendPosition ? scatterStyle.legendPosition.top || 50 : 50,
|
|
|
- legendBottom: scatterStyle.legendPosition ? scatterStyle.legendPosition.bottom || 50 : 50,
|
|
|
- });
|
|
|
- dispatch({ type: 'chartDesigner/setFields', fields: [
|
|
|
- { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { gridPosition: { bottom: value} } }) },
|
|
|
- { name: 'chartOption', value: deepAssign(chartOption, { grid: {
|
|
|
- bottom: (value && value !== 'auto') ? ( // 已设置图域下边距
|
|
|
- value
|
|
|
- ) : gridPosition.bottom,
|
|
|
- } }) },
|
|
|
- ] });
|
|
|
- }}
|
|
|
- />
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- <Row>
|
|
|
- <Col span={8}>左边距:</Col>
|
|
|
- <Col span={16}>
|
|
|
- <Input
|
|
|
- key={`scatter-grid-position-left-${scatterStyle.gridPosition ? scatterStyle.gridPosition['left'] : null}`}
|
|
|
- defaultValue={scatterStyle.gridPosition ? scatterStyle.gridPosition['left'] : null}
|
|
|
- placeholder='5%'
|
|
|
- onBlur={e => {
|
|
|
- let value = e.target.value;
|
|
|
- let gridPosition = adapteGridPosition({
|
|
|
- legendHidden: !!groupBy && !!groupBy.key ? scatterStyle.legendHidden : true,
|
|
|
- legendOrient: scatterStyle.legendOrient || 'vertical',
|
|
|
- legendLeft: scatterStyle.legendPosition ? scatterStyle.legendPosition.left || 'auto' : 'auto',
|
|
|
- legendRight: scatterStyle.legendPosition ? scatterStyle.legendPosition.right || '5%' : '5%',
|
|
|
- legendTop: scatterStyle.legendPosition ? scatterStyle.legendPosition.top || 50 : 50,
|
|
|
- legendBottom: scatterStyle.legendPosition ? scatterStyle.legendPosition.bottom || 50 : 50,
|
|
|
- });
|
|
|
- dispatch({ type: 'chartDesigner/setFields', fields: [
|
|
|
- { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { gridPosition: { left: value} } }) },
|
|
|
- { name: 'chartOption', value: deepAssign(chartOption, { grid: {
|
|
|
- left: (value && value !== 'auto') ? ( // 已设置图域左边距
|
|
|
- value
|
|
|
- ) : gridPosition.left,
|
|
|
- } }) },
|
|
|
- ] });
|
|
|
- }}
|
|
|
- />
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- <Row>
|
|
|
- <Col span={8}>右边距:</Col>
|
|
|
- <Col span={16}>
|
|
|
- <Input
|
|
|
- key={`scatter-grid-position-right-${scatterStyle.gridPosition ? scatterStyle.gridPosition['right'] : null}`}
|
|
|
- defaultValue={scatterStyle.gridPosition ? scatterStyle.gridPosition['right'] : null}
|
|
|
- placeholder='5%'
|
|
|
- onBlur={e => {
|
|
|
- let value = e.target.value;
|
|
|
- let gridPosition = adapteGridPosition({
|
|
|
- legendHidden: !!groupBy && !!groupBy.key ? scatterStyle.legendHidden : true,
|
|
|
- legendOrient: scatterStyle.legendOrient || 'vertical',
|
|
|
- legendLeft: scatterStyle.legendPosition ? scatterStyle.legendPosition.left || 'auto' : 'auto',
|
|
|
- legendRight: scatterStyle.legendPosition ? scatterStyle.legendPosition.right || '5%' : '5%',
|
|
|
- legendTop: scatterStyle.legendPosition ? scatterStyle.legendPosition.top || 50 : 50,
|
|
|
- legendBottom: scatterStyle.legendPosition ? scatterStyle.legendPosition.bottom || 50 : 50,
|
|
|
- });
|
|
|
- dispatch({ type: 'chartDesigner/setFields', fields: [
|
|
|
- { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { gridPosition: { right: value} } }) },
|
|
|
- { name: 'chartOption', value: deepAssign(chartOption, { grid: {
|
|
|
- right: (value !== '' && value !== 'auto') ? ( // 已设置图域右边距
|
|
|
- value
|
|
|
- ) : gridPosition.right
|
|
|
- } }) },
|
|
|
- ] });
|
|
|
- }}
|
|
|
- />
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- </Form.Item>
|
|
|
<Divider>标注</Divider>
|
|
|
<Form.Item label='标注符号' {...formItemLayout}>
|
|
|
<Select
|
|
|
@@ -323,202 +203,6 @@ class ScatterStyle extends React.Component {
|
|
|
}}
|
|
|
/>
|
|
|
</FormItem>
|
|
|
- {!!groupBy && !!groupBy.key && <Divider>图例</Divider>}
|
|
|
- {!!groupBy && !!groupBy.key && <Row>
|
|
|
- <Col span={!!scatterStyle.legendHidden ? 24 : 12}>
|
|
|
- <Form.Item label='隐藏' labelCol={{ span: !!scatterStyle.legendHidden ? 8 : 16 }} wrapperCol={{ span: !!scatterStyle.legendHidden ? 16 : 8 }}>
|
|
|
- <Checkbox
|
|
|
- checked={!!scatterStyle.legendHidden}
|
|
|
- onChange={e => {
|
|
|
- let checked = e.target.checked;
|
|
|
- let gridPosition = adapteGridPosition({
|
|
|
- legendHidden: checked,
|
|
|
- legendOrient: scatterStyle.legendOrient || 'vertical',
|
|
|
- legendLeft: scatterStyle.legendPosition ? scatterStyle.legendPosition.left || 'auto' : 'auto',
|
|
|
- legendRight: scatterStyle.legendPosition ? scatterStyle.legendPosition.right || '5%' : '5%',
|
|
|
- legendTop: scatterStyle.legendPosition ? scatterStyle.legendPosition.top || 50 : 50,
|
|
|
- legendBottom: scatterStyle.legendPosition ? scatterStyle.legendPosition.bottom || 50 : 50,
|
|
|
- });
|
|
|
- dispatch({ type: 'chartDesigner/setFields', fields: [
|
|
|
- { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { legendHidden: checked } }) },
|
|
|
- { name: 'chartOption', value: deepAssign(chartOption, { legend: { show: !checked }, grid: {
|
|
|
- left: gridPosition.left,
|
|
|
- right: gridPosition.right,
|
|
|
- top: gridPosition.top,
|
|
|
- bottom: gridPosition.bottom,
|
|
|
- } }) },
|
|
|
- ] });
|
|
|
- }}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- </Col>
|
|
|
- {!!groupBy && !!groupBy.key && !scatterStyle.legendHidden && <Col span={12}>
|
|
|
- <Form.Item label='分页' labelCol={{ span: 16 }} wrapperCol={{ span: 8 }}>
|
|
|
- <Checkbox
|
|
|
- checked={!!scatterStyle.legendInPagination}
|
|
|
- onChange={e => {
|
|
|
- let checked = e.target.checked;
|
|
|
- dispatch({ type: 'chartDesigner/setFields', fields: [
|
|
|
- { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { legendInPagination: checked } }) },
|
|
|
- { name: 'chartOption', value: deepAssign(chartOption, { legend: { type: checked ? 'scroll' : 'plain' } }) },
|
|
|
- ] });
|
|
|
- }}
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- </Col>}
|
|
|
- </Row>}
|
|
|
- {!!groupBy && !!groupBy.key && !scatterStyle.legendHidden && <Form.Item label='排布方向' {...formItemLayout}>
|
|
|
- <Select
|
|
|
- defaultValue={scatterStyle.legendOrient || 'vertical'}
|
|
|
- onChange={(value, item) => {
|
|
|
- let gridPosition = adapteGridPosition({
|
|
|
- legendHidden: !!groupBy && !!groupBy.key ? scatterStyle.legendHidden : true,
|
|
|
- legendOrient: value,
|
|
|
- legendLeft: scatterStyle.legendPosition ? scatterStyle.legendPosition.left || 'auto' : 'auto',
|
|
|
- legendRight: scatterStyle.legendPosition ? scatterStyle.legendPosition.right || '5%' : '5%',
|
|
|
- legendTop: scatterStyle.legendPosition ? scatterStyle.legendPosition.top || 50 : 50,
|
|
|
- legendBottom: scatterStyle.legendPosition ? scatterStyle.legendPosition.bottom || 50 : 50,
|
|
|
- });
|
|
|
- dispatch({ type: 'chartDesigner/setFields', fields: [
|
|
|
- { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { legendOrient: value } }) },
|
|
|
- { name: 'chartOption', value: deepAssign(chartOption, {
|
|
|
- legend: { orient: value },
|
|
|
- grid: {
|
|
|
- top: gridPosition.top,
|
|
|
- left: gridPosition.left,
|
|
|
- bottom: gridPosition.bottom,
|
|
|
- right: gridPosition.right,
|
|
|
- },
|
|
|
- }) },
|
|
|
- ] });
|
|
|
- }}
|
|
|
- >
|
|
|
- <Select.Option value='vertical'>纵向排布</Select.Option>
|
|
|
- <Select.Option value='horizontal'>横向排布</Select.Option>
|
|
|
- </Select>
|
|
|
- </Form.Item>}
|
|
|
- {!!groupBy && !!groupBy.key && !scatterStyle.legendHidden && <Form.Item label='位置' {...formItemLayout}>
|
|
|
- <Row>
|
|
|
- <Col span={8}>上边距:</Col>
|
|
|
- <Col span={16}>
|
|
|
- <Input
|
|
|
- defaultValue={scatterStyle.legendPosition ? scatterStyle.legendPosition['top'] : null}
|
|
|
- placeholder={50}
|
|
|
- onBlur={e => {
|
|
|
- let value = e.target.value;
|
|
|
- let legendTop = (value === '' || value === null || value === undefined) ? 50 : value;
|
|
|
- let gridPosition = adapteGridPosition({
|
|
|
- legendHidden: !!groupBy && !!groupBy.key ? scatterStyle.legendHidden : true,
|
|
|
- legendOrient: scatterStyle.legendOrient || 'vertical',
|
|
|
- legendLeft: scatterStyle.legendPosition ? scatterStyle.legendPosition.left || 'auto' : 'auto',
|
|
|
- legendRight: scatterStyle.legendPosition ? scatterStyle.legendPosition.right || '5%' : '5%',
|
|
|
- legendTop,
|
|
|
- legendBottom: scatterStyle.legendPosition ? scatterStyle.legendPosition.bottom || 50 : 50,
|
|
|
- });
|
|
|
- dispatch({ type: 'chartDesigner/setFields', fields: [
|
|
|
- { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { legendPosition: { top: value}, gridPosition: { top: gridPosition.top } } }) },
|
|
|
- { name: 'chartOption', value: deepAssign(chartOption, { legend: {
|
|
|
- top: legendTop,
|
|
|
- }, grid: {
|
|
|
- top: gridPosition.top,
|
|
|
- bottom: gridPosition.bottom,
|
|
|
- } }) },
|
|
|
- ] });
|
|
|
- }}
|
|
|
- />
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- <Row>
|
|
|
- <Col span={8}>下边距:</Col>
|
|
|
- <Col span={16}>
|
|
|
- <Input
|
|
|
- defaultValue={scatterStyle.legendPosition ? scatterStyle.legendPosition['bottom'] : null}
|
|
|
- placeholder={50}
|
|
|
- onBlur={e => {
|
|
|
- let value = e.target.value;
|
|
|
- let legendBottom = (value === '' || value === null || value === undefined) ? 50 : value;
|
|
|
- let gridPosition = adapteGridPosition({
|
|
|
- legendHidden: !!groupBy && !!groupBy.key ? scatterStyle.legendHidden : true,
|
|
|
- legendOrient: scatterStyle.legendOrient || 'vertical',
|
|
|
- legendLeft: scatterStyle.legendPosition ? scatterStyle.legendPosition.left || 'auto' : 'auto',
|
|
|
- legendRight: scatterStyle.legendPosition ? scatterStyle.legendPosition.right || '5%' : '5%',
|
|
|
- legendTop: scatterStyle.legendPosition ? scatterStyle.legendPosition.top || 50 : 50,
|
|
|
- legendBottom,
|
|
|
- });
|
|
|
- dispatch({ type: 'chartDesigner/setFields', fields: [
|
|
|
- { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { legendPosition: { bottom: value}, gridPosition: { bottom: gridPosition.bottom } } }) },
|
|
|
- { name: 'chartOption', value: deepAssign(chartOption, { legend: {
|
|
|
- bottom: legendBottom
|
|
|
- }, grid: {
|
|
|
- top: gridPosition.top,
|
|
|
- bottom: gridPosition.bottom
|
|
|
- } }) },
|
|
|
- ] });
|
|
|
- }}
|
|
|
- />
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- <Row>
|
|
|
- <Col span={8}>左边距:</Col>
|
|
|
- <Col span={16}>
|
|
|
- <Input
|
|
|
- defaultValue={scatterStyle.legendPosition ? scatterStyle.legendPosition['left'] : null}
|
|
|
- placeholder='auto'
|
|
|
- onBlur={e => {
|
|
|
- let value = e.target.value;
|
|
|
- let legendLeft = (value === '' || value === null || value === undefined) ? 'auto' : value;
|
|
|
- let gridPosition = adapteGridPosition({
|
|
|
- legendHidden: !!groupBy && !!groupBy.key ? scatterStyle.legendHidden : true,
|
|
|
- legendOrient: scatterStyle.legendOrient || 'vertical',
|
|
|
- legendLeft,
|
|
|
- legendRight: scatterStyle.legendPosition ? scatterStyle.legendPosition.right || '5%' : '5%',
|
|
|
- legendTop: scatterStyle.legendPosition ? scatterStyle.legendPosition.top || 50 : 50,
|
|
|
- legendBottom: scatterStyle.legendPosition ? scatterStyle.legendPosition.bottom || 50 : 50,
|
|
|
- });
|
|
|
- dispatch({ type: 'chartDesigner/setFields', fields: [
|
|
|
- { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { legendPosition: { left: value }, gridPosition: { left: gridPosition.left } } }) },
|
|
|
- { name: 'chartOption', value: deepAssign(chartOption, { legend: {
|
|
|
- left: legendLeft,
|
|
|
- }, grid: {
|
|
|
- left: gridPosition.left,
|
|
|
- right: gridPosition.right
|
|
|
- } }) },
|
|
|
- ] });
|
|
|
- }}
|
|
|
- />
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- <Row>
|
|
|
- <Col span={8}>右边距:</Col>
|
|
|
- <Col span={16}>
|
|
|
- <Input
|
|
|
- defaultValue={scatterStyle.legendPosition ? scatterStyle.legendPosition['right'] : null}
|
|
|
- placeholder='5%'
|
|
|
- onBlur={e => {
|
|
|
- let value = e.target.value;
|
|
|
- let legendRight = (value === '' || value === null || value === undefined) ? '5%' : value;
|
|
|
- let gridPosition = adapteGridPosition({
|
|
|
- legendHidden: !!groupBy && !!groupBy.key ? scatterStyle.legendHidden : true,
|
|
|
- legendOrient: scatterStyle.legendOrient || 'vertical',
|
|
|
- legendLeft: scatterStyle.legendPosition ? scatterStyle.legendPosition.left || 'auto' : 'auto',
|
|
|
- legendRight,
|
|
|
- legendTop: scatterStyle.legendPosition ? scatterStyle.legendPosition.top || 50 : 50,
|
|
|
- legendBottom: scatterStyle.legendPosition ? scatterStyle.legendPosition.bottom || 50 : 50,
|
|
|
- });
|
|
|
- dispatch({ type: 'chartDesigner/setFields', fields: [
|
|
|
- { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { legendPosition: { right: value}, gridPosition: { right: gridPosition.right } } }) },
|
|
|
- { name: 'chartOption', value: deepAssign(chartOption, { legend: {
|
|
|
- right: legendRight
|
|
|
- }, grid: {
|
|
|
- left: gridPosition.left,
|
|
|
- right: gridPosition.right
|
|
|
- } }) },
|
|
|
- ] });
|
|
|
- }}
|
|
|
- />
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- </Form.Item>}
|
|
|
</Form>
|
|
|
}
|
|
|
}
|