|
|
@@ -2,6 +2,7 @@ import React from 'react'
|
|
|
import { connect } from 'dva'
|
|
|
import { Input, InputNumber, Form, Checkbox, Select, Tooltip, Divider, Row, Col } from 'antd'
|
|
|
import { deepAssign } from '../../../../utils/baseUtils'
|
|
|
+import adapteGridPosition from '../../../../models/adapteGridPosition'
|
|
|
const FormItem = Form.Item;
|
|
|
|
|
|
class ScatterStyle extends React.Component {
|
|
|
@@ -35,25 +36,20 @@ class ScatterStyle extends React.Component {
|
|
|
placeholder={50}
|
|
|
onBlur={e => {
|
|
|
let value = e.target.value;
|
|
|
- let legendVisible = chartOption.legend.show,
|
|
|
- legendOrient = chartOption.legend.orient,
|
|
|
- legendTop = chartOption.legend.top;
|
|
|
+ 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
|
|
|
- ) : ( // 未设置图域上边距或设置自适应
|
|
|
- (legendVisible) ? ( // 图例未隐藏
|
|
|
- legendOrient === 'horizontal' ? ( //图例排布方向为水平
|
|
|
- legendTop === 'auto' ? 50 // 已知图例上边距未设置
|
|
|
- : ( // 图例上边距已设置
|
|
|
- (legendTop+'').endsWith('%') ? (10 + Number(legendTop.replace('%', '')) + '%') // 图例上边距为百分比,图域左边距增加10%
|
|
|
- : (50 + Number(legendTop))// 图例上边距为数字,图域上边距增加50
|
|
|
- )
|
|
|
- ) : 50
|
|
|
- ) : 50 // 图例隐藏
|
|
|
- ),
|
|
|
+ ) : gridPosition.top,
|
|
|
} }) },
|
|
|
] });
|
|
|
}}
|
|
|
@@ -69,28 +65,20 @@ class ScatterStyle extends React.Component {
|
|
|
placeholder={50}
|
|
|
onBlur={e => {
|
|
|
let value = e.target.value;
|
|
|
- let legendVisible = chartOption.legend.show,
|
|
|
- legendOrient = chartOption.legend.orient,
|
|
|
- legendTop = chartOption.legend.top,
|
|
|
- legendBottom = chartOption.legend.bottom;
|
|
|
+ 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
|
|
|
- ) : ( // 未设置图域下边距或设置自适应
|
|
|
- (legendVisible) ? ( // 图例未隐藏
|
|
|
- legendOrient === 'horizontal' ? ( //图例排布方向为水平
|
|
|
- legendTop === 'auto' ? ( // 图例上边距未设置
|
|
|
- legendBottom === 'auto' ? 50 // 已知图例下边距未设置
|
|
|
- : ( // 图例下边距已设置
|
|
|
- (legendBottom + '').endsWith('%') ? (10 + Number(legendBottom.replace('%', '')) + '%') // 图例下边距为百分比,图域下边距增加10%
|
|
|
- : (50 + Number(legendBottom))// 图例下边距为数字,图域下边距增加50
|
|
|
- )
|
|
|
- ) : 50
|
|
|
- ) : 50
|
|
|
- ) : 50 // 图例隐藏
|
|
|
- ),
|
|
|
+ ) : gridPosition.bottom,
|
|
|
} }) },
|
|
|
] });
|
|
|
}}
|
|
|
@@ -106,28 +94,20 @@ class ScatterStyle extends React.Component {
|
|
|
placeholder='5%'
|
|
|
onBlur={e => {
|
|
|
let value = e.target.value;
|
|
|
- let legendVisible = chartOption.legend.show,
|
|
|
- legendOrient = chartOption.legend.orient,
|
|
|
- legendLeft = chartOption.legend.left,
|
|
|
- legendRight = chartOption.legend.right;
|
|
|
+ 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
|
|
|
- ) : ( // 未设置图域左边距或设置自适应
|
|
|
- (legendVisible) ? ( // 图例未隐藏
|
|
|
- legendOrient === 'vertical' ? ( //图例排布方向为垂直
|
|
|
- legendLeft === 'auto' ? ( // 已知图例左边距未设置
|
|
|
- legendRight === 'auto' ? '10%' // 图例右边距也未设置,将靠左对齐,图域左边距增加
|
|
|
- : '5%' // 图例右边距已设置
|
|
|
- ) : ( // 图例左边距已设置
|
|
|
- (legendLeft + '').endsWith('%') ? (10 + Number(legendLeft.replace('%', '')) + '%') // 图例左边距为百分比,图域左边距增加10%
|
|
|
- : (100 + Number(legendLeft))// 图例左边距为数字,图域左边距增加100
|
|
|
- )
|
|
|
- ) : '5%'
|
|
|
- ) : '5%' // 图例隐藏
|
|
|
- ),
|
|
|
+ ) : gridPosition.left,
|
|
|
} }) },
|
|
|
] });
|
|
|
}}
|
|
|
@@ -143,28 +123,20 @@ class ScatterStyle extends React.Component {
|
|
|
placeholder='5%'
|
|
|
onBlur={e => {
|
|
|
let value = e.target.value;
|
|
|
- let legendVisible = chartOption.legend.show,
|
|
|
- legendOrient = chartOption.legend.orient,
|
|
|
- legendTop = chartOption.legend.top,
|
|
|
- legendRight = chartOption.legend.right;
|
|
|
+ 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
|
|
|
- ) : ( // 未设置图域右边距或设置自适应
|
|
|
- (legendVisible) ? ( // 图例未隐藏
|
|
|
- legendOrient === 'vertical' ? ( //图例排布方向为垂直
|
|
|
- legendTop === 'auto' ? ( // 图例左边距未设置
|
|
|
- legendRight === 'auto' ? '5%' // 已知图例右边距未设置
|
|
|
- : ( // 图例右边距已设置
|
|
|
- (legendRight + '').endsWith('%') ? (10 + Number(legendRight.replace('%', '')) + '%') // 图例右边距为百分比,图域右边距增加10%
|
|
|
- : (100 + Number(legendRight))// 图例右边距为数字,图域右边距增加100
|
|
|
- )
|
|
|
- ) : '5%'
|
|
|
- ) : '5%'
|
|
|
- ) : '5%' // 图例隐藏
|
|
|
- )
|
|
|
+ ) : gridPosition.right
|
|
|
} }) },
|
|
|
] });
|
|
|
}}
|
|
|
@@ -358,67 +330,21 @@ class ScatterStyle extends React.Component {
|
|
|
checked={!!scatterStyle.legendHidden}
|
|
|
onChange={e => {
|
|
|
let checked = e.target.checked;
|
|
|
- let 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,
|
|
|
- gridPositionLeft = checked ? '5%' : ( // 隐藏图例直接将图域左边距设为5%
|
|
|
- legendOrient === 'vertical' ? ( // 图例排布方向为垂直
|
|
|
- legendLeft === 'auto' ? ( // 已知图例左边距未设置
|
|
|
- legendRight === 'auto' ? '10%' // 图例右边距也未设置,将靠左对齐,图域左边距增加
|
|
|
- : '5%' // 图例右边距已设置
|
|
|
- ) : ( // 图例左边距已设置
|
|
|
- (legendLeft + '').endsWith('%') ? (10 + Number(legendLeft.replace('%', '')) + '%') // 图例左边距为百分比,图域左边距增加10%
|
|
|
- : (100 + Number(legendLeft))// 图例左边距为数字,图域左边距增加100
|
|
|
- )
|
|
|
- ) : '5%'
|
|
|
- ),
|
|
|
- gridPositionRight = checked ? '5%' : ( // 隐藏图例直接将图域右边距设为5%
|
|
|
- legendOrient === 'vertical' ? ( // 图例排布方向为垂直
|
|
|
- legendLeft === 'auto' ? (
|
|
|
- legendRight === 'auto' ? '5%' // 已知图例右边距未设置
|
|
|
- : ( // 图例右边距已设置
|
|
|
- (legendRight + '').endsWith('%') ? (10 + Number(legendRight.replace('%', '')) + '%') // 图例右边距为百分比,图域右边距增加10%
|
|
|
- : (100 + Number(legendRight))// 图例右边距为数字,图域右边距增加100
|
|
|
- )
|
|
|
- ) : '5%'
|
|
|
- ) : '5%'
|
|
|
- ),
|
|
|
- gridPositionTop = checked ? 50: ( // 图例未隐藏
|
|
|
- legendOrient === 'horizontal' ? ( // 图例排布方向为水平
|
|
|
- legendTop === 'auto' ? ( // 已知图例上边距未设置
|
|
|
- legendBottom === 'auto' ? 50 // 图例下边距也未设置,将靠上对齐,图域上边距保持50
|
|
|
- : 50 // 图例下边距已设置
|
|
|
- ) : ( // 图例上边距已设置
|
|
|
- (legendTop + '').endsWith('%') ? (10 + Number(legendTop.replace('%', '')) + '%') // 图例上边距为百分比,图域上边距增加10%
|
|
|
- : (50 + Number(legendTop))// 图例上边距为数字,图域上边距增加50
|
|
|
- )
|
|
|
- ) : 50
|
|
|
- ),
|
|
|
- gridPositionBottom = checked ? 50 : ( // 图例未隐藏
|
|
|
- legendOrient === 'horizontal' ? ( // 图例排布方向为水平
|
|
|
- legendTop === 'auto' ? ( // 图例上边距未设置
|
|
|
- legendBottom === 'auto' ? 50 // 已知图例下边距未设置
|
|
|
- : ( // 图例下边距已设置
|
|
|
- (legendBottom + '').endsWith('%') ? (10 + Number(legendBottom.replace('%', '')) + '%') // 图例下边距为百分比,图域下边距增加10%
|
|
|
- : (50 + Number(legendBottom))// 图例下边距为数字,图域下边距增加50
|
|
|
- )
|
|
|
- ) : 50
|
|
|
- ) : 50
|
|
|
- );
|
|
|
+ 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, gridPosition: {
|
|
|
- left: gridPositionLeft,
|
|
|
- right: gridPositionRight,
|
|
|
- top: gridPositionTop,
|
|
|
- bottom: gridPositionBottom,
|
|
|
- } } }) },
|
|
|
+ { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { legendHidden: checked } }) },
|
|
|
{ name: 'chartOption', value: deepAssign(chartOption, { legend: { show: !checked }, grid: {
|
|
|
- left: gridPositionLeft,
|
|
|
- right: gridPositionRight,
|
|
|
- top: gridPositionTop,
|
|
|
- bottom: gridPositionBottom,
|
|
|
+ left: gridPosition.left,
|
|
|
+ right: gridPosition.right,
|
|
|
+ top: gridPosition.top,
|
|
|
+ bottom: gridPosition.bottom,
|
|
|
} }) },
|
|
|
] });
|
|
|
}}
|
|
|
@@ -444,9 +370,25 @@ class ScatterStyle extends React.Component {
|
|
|
<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 } }) },
|
|
|
+ { name: 'chartOption', value: deepAssign(chartOption, {
|
|
|
+ legend: { orient: value },
|
|
|
+ grid: {
|
|
|
+ top: gridPosition.top,
|
|
|
+ left: gridPosition.left,
|
|
|
+ bottom: gridPosition.bottom,
|
|
|
+ right: gridPosition.right,
|
|
|
+ },
|
|
|
+ }) },
|
|
|
] });
|
|
|
}}
|
|
|
>
|
|
|
@@ -463,27 +405,22 @@ class ScatterStyle extends React.Component {
|
|
|
placeholder={50}
|
|
|
onBlur={e => {
|
|
|
let value = e.target.value;
|
|
|
- let legendHidden = scatterStyle.legendHidden,
|
|
|
- legendOrient = scatterStyle.legendOrient || 'vertical',
|
|
|
- legendTop = (value === '' || value === null || value === undefined) ? 50 : value,
|
|
|
- legendBottom = scatterStyle.legendPosition ? scatterStyle.legendPosition.bottom || 50 : 50,
|
|
|
- gridPositionTop = !legendHidden ? ( // 图例未隐藏
|
|
|
- legendOrient === 'horizontal' ? ( // 图例排布方向为水平
|
|
|
- legendTop === 'auto' ? ( // 已知图例上边距未设置
|
|
|
- legendBottom === 'auto' ? 50 // 图例下边距也未设置,将靠上对齐,图域上边距保持50
|
|
|
- : 50 // 图例下边距已设置
|
|
|
- ) : ( // 图例上边距已设置
|
|
|
- (legendTop + '').endsWith('%') ? (10 + Number(legendTop.replace('%', '')) + '%') // 图例上边距为百分比,图域上边距增加10%
|
|
|
- : (50 + Number(legendTop))// 图例上边距为数字,图域上边距增加50
|
|
|
- )
|
|
|
- ) : 50
|
|
|
- ) : 50 // 图例隐藏
|
|
|
+ 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: gridPositionTop } } }) },
|
|
|
+ { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { legendPosition: { top: value}, gridPosition: { top: gridPosition.top } } }) },
|
|
|
{ name: 'chartOption', value: deepAssign(chartOption, { legend: {
|
|
|
top: legendTop,
|
|
|
}, grid: {
|
|
|
- top: gridPositionTop
|
|
|
+ top: gridPosition.top,
|
|
|
+ bottom: gridPosition.bottom,
|
|
|
} }) },
|
|
|
] });
|
|
|
}}
|
|
|
@@ -498,27 +435,22 @@ class ScatterStyle extends React.Component {
|
|
|
placeholder={50}
|
|
|
onBlur={e => {
|
|
|
let value = e.target.value;
|
|
|
- let legendHidden = scatterStyle.legendHidden,
|
|
|
- legendOrient = scatterStyle.legendOrient || 'vertical',
|
|
|
- legendTop = scatterStyle.legendPosition ? scatterStyle.legendPosition.top || 50 : 50,
|
|
|
- legendBottom = (value === '' || value === null || value === undefined) ? 50 : value,
|
|
|
- gridPositionBottom = !legendHidden ? ( // 图例未隐藏
|
|
|
- legendOrient === 'horizontal' ? ( // 图例排布方向为水平
|
|
|
- legendTop === 'auto' ? ( // 图例上边距未设置
|
|
|
- legendBottom === 'auto' ? 50 // 已知图例下边距未设置
|
|
|
- : ( // 图例下边距已设置
|
|
|
- (legendBottom + '').endsWith('%') ? (10 + Number(legendBottom.replace('%', '')) + '%') // 图例下边距为百分比,图域下边距增加10%
|
|
|
- : (50 + Number(legendBottom))// 图例下边距为数字,图域下边距增加50
|
|
|
- )
|
|
|
- ) : 50
|
|
|
- ) : 50
|
|
|
- ) : 50 // 图例隐藏
|
|
|
+ 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: gridPositionBottom } } }) },
|
|
|
+ { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { legendPosition: { bottom: value}, gridPosition: { bottom: gridPosition.bottom } } }) },
|
|
|
{ name: 'chartOption', value: deepAssign(chartOption, { legend: {
|
|
|
bottom: legendBottom
|
|
|
}, grid: {
|
|
|
- bottom: gridPositionBottom
|
|
|
+ top: gridPosition.top,
|
|
|
+ bottom: gridPosition.bottom
|
|
|
} }) },
|
|
|
] });
|
|
|
}}
|
|
|
@@ -533,27 +465,22 @@ class ScatterStyle extends React.Component {
|
|
|
placeholder='auto'
|
|
|
onBlur={e => {
|
|
|
let value = e.target.value;
|
|
|
- let legendHidden = scatterStyle.legendHidden,
|
|
|
- legendOrient = scatterStyle.legendOrient || 'vertical',
|
|
|
- legendLeft = (value === '' || value === null || value === undefined) ? 'auto' : value,
|
|
|
- legendRight = scatterStyle.legendPosition ? scatterStyle.legendPosition.right || '5%' : '5%',
|
|
|
- gridPositionLeft = !legendHidden ? ( // 图例未隐藏
|
|
|
- legendOrient === 'vertical' ? ( // 图例排布方向为垂直
|
|
|
- legendLeft === 'auto' ? ( // 已知图例左边距未设置
|
|
|
- legendRight === 'auto' ? '10%' // 图例右边距也未设置,将靠左对齐,图域左边距增加
|
|
|
- : '5%' // 图例右边距已设置
|
|
|
- ) : ( // 图例左边距已设置
|
|
|
- (legendLeft + '').endsWith('%') ? (10 + Number(legendLeft.replace('%', '')) + '%') // 图例左边距为百分比,图域左边距增加10%
|
|
|
- : (100 + Number(legendLeft))// 图例左边距为数字,图域左边距增加100
|
|
|
- )
|
|
|
- ) : '5%'
|
|
|
- ) : '5%' // 图例隐藏
|
|
|
+ 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: gridPositionLeft } } }) },
|
|
|
+ { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { legendPosition: { left: value }, gridPosition: { left: gridPosition.left } } }) },
|
|
|
{ name: 'chartOption', value: deepAssign(chartOption, { legend: {
|
|
|
- left: legendLeft
|
|
|
+ left: legendLeft,
|
|
|
}, grid: {
|
|
|
- left: gridPositionLeft
|
|
|
+ left: gridPosition.left,
|
|
|
+ right: gridPosition.right
|
|
|
} }) },
|
|
|
] });
|
|
|
}}
|
|
|
@@ -568,27 +495,22 @@ class ScatterStyle extends React.Component {
|
|
|
placeholder='5%'
|
|
|
onBlur={e => {
|
|
|
let value = e.target.value;
|
|
|
- let legendHidden = scatterStyle.legendHidden,
|
|
|
- legendOrient = scatterStyle.legendOrient || 'vertical',
|
|
|
- legendLeft = scatterStyle.legendPosition ? scatterStyle.legendPosition.left || 'auto' : 'auto',
|
|
|
- legendRight = (value === '' || value === null || value === undefined) ? '5%' : value,
|
|
|
- gridPositionRight = !legendHidden ? ( // 图例未隐藏
|
|
|
- legendOrient === 'vertical' ? ( // 图例排布方向为垂直
|
|
|
- legendLeft === 'auto' ? ( // 图例左边距未设置
|
|
|
- legendRight === 'auto' ? '5%' // 已知图例右边距未设置
|
|
|
- : ( // 图例右边距已设置
|
|
|
- (legendRight + '').endsWith('%') ? (10 + Number(legendRight.replace('%', '')) + '%') // 图例右边距为百分比,图域右边距增加10%
|
|
|
- : (100 + Number(legendRight))// 图例右边距为数字,图域右边距增加100
|
|
|
- )
|
|
|
- ) : '5%'
|
|
|
- ) : '5%'
|
|
|
- ) : '5%' // 图例隐藏
|
|
|
+ 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: gridPositionRight } } }) },
|
|
|
+ { name: 'styleConfig', value: deepAssign(styleConfig, { scatter: { legendPosition: { right: value}, gridPosition: { right: gridPosition.right } } }) },
|
|
|
{ name: 'chartOption', value: deepAssign(chartOption, { legend: {
|
|
|
right: legendRight
|
|
|
}, grid: {
|
|
|
- right: gridPositionRight
|
|
|
+ left: gridPosition.left,
|
|
|
+ right: gridPosition.right
|
|
|
} }) },
|
|
|
] });
|
|
|
}}
|