Просмотр исходного кода

饼图“其它”项暂时限制钻取

zhuth 6 лет назад
Родитель
Сommit
fc546653ab

+ 1 - 1
src/components/chartDesigner/charts/echartsView.jsx

@@ -130,7 +130,7 @@ class EchartsView extends Component {
             case 'pie':{
                 //饼图如果是其它 并且tooMany(后台判断有 其他 部分) 为 true 时 不能下钻
                 if( xValue==='其它' && chartOption.baseOption.originConfig.tooMany ){
-                    message.warning('其它类型无法钻取');
+                    message.warning('其它类型无法钻取');
                     return false;
                 }
                 drillDown.push({

+ 35 - 8
src/components/chartDesigner/sections/pieConfigForm.jsx

@@ -1,16 +1,17 @@
 import React from 'react'
-import { Form, InputNumber, Checkbox } from 'antd'
+import { Form, InputNumber, Select, Checkbox } from 'antd'
 import { connect } from 'dva'
 import XAxisItem from './xAxisItem';
 import YAxisItem from './yAxisItem';
 import DrillList from './drillList';
 import GRANULARITY from './granularity.json';
-import { deepAssign } from '../../../utils/baseUtils'
-const FormItem = Form.Item
+
+const { Option } = Select;
+const FormItem = Form.Item;
 const formItemLayout = {
 	labelCol: { span: 8 },
 	wrapperCol: { span: 16 },
-}
+};
 const PieConfigForm = ({ autoRefresh, chartDesigner, dispatch }) => {
 	const { columns, baseConfig, pieConfig } = chartDesigner;
 
@@ -33,6 +34,32 @@ const PieConfigForm = ({ autoRefresh, chartDesigner, dispatch }) => {
 					dispatch({ type: 'chartDesigner/changeField', name: 'pieConfig', value: { ...pieConfig, yAxis: { column, gauge } }, autoRefresh });
 				}}/>
 			</FormItem>
+			{/* <FormItem label='排序目标' {...formItemLayout}>
+				<Select
+					placeholder='扇区索引'
+					allowClear={true}
+					onChange={(value) => {
+						dispatch({ type: 'chartDesigner/changeField', name: 'pieConfig', value: { ...pieConfig, sortTarget: value }, autoRefresh });
+					}}
+					value={pieConfig.sortTarget}
+				>
+					<Option value='x'>扇区索引</Option>
+					<Option value='y'>值</Option>
+				</Select>
+			</FormItem>
+			<FormItem label='排序方式' {...formItemLayout}>
+				<Select
+					placeholder='升序'
+					allowClear={true}
+					onChange={(value) => {
+						dispatch({ type: 'chartDesigner/changeField', name: 'pieConfig', value: { ...pieConfig, sortType: value }, autoRefresh });
+					}}
+					value={pieConfig.sortType}
+				>
+					<Option value='ASC'>升序</Option>
+					<Option value='DESC'>降序</Option>
+				</Select>
+			</FormItem> */}
 			<FormItem label='阈值' {...formItemLayout}>
 				<InputNumber
 					defaultValue={chartDesigner.pieConfig.threshold}
@@ -40,16 +67,16 @@ const PieConfigForm = ({ autoRefresh, chartDesigner, dispatch }) => {
                     onBlur={e => {
 						let value = e.target.value;
 						if(value !== chartDesigner.pieConfig.threshold) {
-							let fields = [{ name: 'pieConfig', value: deepAssign(chartDesigner.pieConfig, { threshold: value }) }];
-							dispatch({ type: 'chartDesigner/changeFields', fields });
+							let fields = [{ name: 'pieConfig', value: { ...pieConfig, threshold: value } }];
+							dispatch({ type: 'chartDesigner/changeFields', fields, autoRefresh });
 						}
                     }}
                     onKeyDown={e => {
                         if(e.keyCode === 13) {
                             let value = e.target.value;
 							if(value !== chartDesigner.pieConfig.threshold) {
-								let fields = [{ name: 'pieConfig', value: deepAssign(chartDesigner.pieConfig, { threshold: value }) }];
-								dispatch({ type: 'chartDesigner/changeFields', fields });
+								let fields = [{ name: 'pieConfig', value: { ...pieConfig, threshold: value } }];
+								dispatch({ type: 'chartDesigner/changeFields', fields, autoRefresh });
 							}
                         }
                     }}

+ 4 - 2
src/models/chartDesigner.js

@@ -68,7 +68,7 @@ export default {
             dataViewConfig: { viewColumns: [], sortColumn: {key: ''}, sortType: 'asc' },
             barConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {key:''}, sortTarget: 'x', sortType: 'ASC', threshold: 20, drillable: false, drillList: [{ column: {}, granularity:{} }] },
             lineConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {key:''}, threshold: 200, drillable: false, drillList: [{ column: {}, granularity:{} }] },
-            pieConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, threshold: 20, drillable: false, drillList: [{ column: {}, granularity:{} }] },
+            pieConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, sortTarget: 'x', sortType: 'ASC', threshold: 20, drillable: false, drillList: [{ column: {}, granularity:{} }] },
             scatterConfig: { xAxis: { column: {}, granularity: {} }, yAxis: { column: {}, gauge: {} }, groupBy: {key:''}, threshold: 1000 },
             indicatorConfig: { xAxis: { column: {} }, yAxis: { column: {}, gauge: {} }, otherColumn: [], threshold: 6 },
             theme: 'default',
@@ -595,7 +595,9 @@ export default {
                         showDataType: pieConfig.yAxis.gauge.value
                     },
                     filters: getBodyFilters(filters),
-                    maxCount: pieConfig.threshold || defaultPieThreshold
+                    maxCount: pieConfig.threshold || defaultPieThreshold,
+                    sort: pieConfig.sortTarget ? (pieConfig.sortTarget === 'y' ? pieConfig.yAxis.column.value : pieConfig.xAxis.column.value) : pieConfig.xAxis.column.value,
+                    rule: pieConfig.sortType || 'ASC',
                 };
 
                 //钻取逻辑

+ 2 - 0
src/models/parseChartOption.js

@@ -367,6 +367,8 @@ function pieOption(data, pieConfig, themeConfig, styleConfig, drillDown) {
                 obj.value = numberFormat(obj.value)
                 if(!v.name) {
                     obj.name = '空'
+                }else if(v.name === '其它') {
+                    obj.name = v.name;
                 }else {
                     let gv= xGranularityV;
                     if(gv === 'halfYear') {