|
|
@@ -290,7 +290,7 @@ export default {
|
|
|
yield put({ type: 'silentSetField', name: 'columns', value: [] });
|
|
|
}
|
|
|
},
|
|
|
- // 因为数据源列字段可能发生重命名,需要替换到最新的别名
|
|
|
+ // 因为数据源列字段可能发生重命名,需要替换到最新的列
|
|
|
*updateColumns(action, { select, call, put }) {
|
|
|
const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
const { columns, baseConfig } = chartDesigner;
|
|
|
@@ -301,22 +301,22 @@ export default {
|
|
|
const { xAxis, yAxis, groupBy } = barConfig;
|
|
|
const newXAxisColumn = columns.find(c => c.name === xAxis.column.value);
|
|
|
const newYAxisColumn = columns.find(c => c.name === yAxis.column.value);
|
|
|
- const newGroupByColumn = columns.find(c => c.name === groupBy.key);
|
|
|
+ const newGroupByColumn = groupBy ? columns.find(c => c.name === groupBy.key) : null;
|
|
|
let fields = {};
|
|
|
- newXAxisColumn ? fields.xAxis = { column: { label: newXAxisColumn.label } } : void(0);
|
|
|
- newYAxisColumn ? fields.yAxis = { column: { label: newYAxisColumn.label } } : void(0);
|
|
|
- newGroupByColumn ? fields.groupBy = { label: newGroupByColumn.label } :void(0);
|
|
|
+ newXAxisColumn ? fields.xAxis = { column: { label: newXAxisColumn.label, type: newXAxisColumn.type } } : void(0);
|
|
|
+ newYAxisColumn ? fields.yAxis = { column: { label: newYAxisColumn.label, type: newYAxisColumn.type } } : void(0);
|
|
|
+ newGroupByColumn ? fields.groupBy = { label: newGroupByColumn.label, type: newGroupByColumn.type } :void(0);
|
|
|
yield put({ type: 'silentSetField', name: 'barConfig', value: deepAssign(barConfig, { ...fields }) });
|
|
|
}else if(viewType === 'line') {
|
|
|
const { lineConfig } = chartDesigner;
|
|
|
const { xAxis, yAxis, groupBy } = lineConfig;
|
|
|
const newXAxisColumn = columns.find(c => c.name === xAxis.column.value);
|
|
|
const newYAxisColumn = columns.find(c => c.name === yAxis.column.value);
|
|
|
- const newGroupByColumn = columns.find(c => c.name === groupBy.key);
|
|
|
+ const newGroupByColumn = groupBy ? columns.find(c => c.name === groupBy.key) : null;
|
|
|
let fields = {};
|
|
|
- newXAxisColumn ? fields.xAxis = { column: { label: newXAxisColumn.label } } : void(0);
|
|
|
- newYAxisColumn ? fields.yAxis = { column: { label: newYAxisColumn.label } } : void(0);
|
|
|
- newGroupByColumn ? fields.groupBy = { label: newGroupByColumn.label } :void(0);
|
|
|
+ newXAxisColumn ? fields.xAxis = { column: { label: newXAxisColumn.label, type: newXAxisColumn.type } } : void(0);
|
|
|
+ newYAxisColumn ? fields.yAxis = { column: { label: newYAxisColumn.label, type: newYAxisColumn.type } } : void(0);
|
|
|
+ newGroupByColumn ? fields.groupBy = { label: newGroupByColumn.label, type: newGroupByColumn.type } :void(0);
|
|
|
yield put({ type: 'silentSetField', name: 'lineConfig', value: deepAssign(lineConfig, { ...fields }) });
|
|
|
}else if(viewType === 'pie') {
|
|
|
const { pieConfig } = chartDesigner;
|
|
|
@@ -324,19 +324,19 @@ export default {
|
|
|
const newXAxisColumn = columns.find(c => c.name === xAxis.column.value);
|
|
|
const newYAxisColumn = columns.find(c => c.name === yAxis.column.value);
|
|
|
let fields = {};
|
|
|
- newXAxisColumn ? fields.xAxis = { column: { label: newXAxisColumn.label } } : void(0);
|
|
|
- newYAxisColumn ? fields.yAxis = { column: { label: newYAxisColumn.label } } : void(0);
|
|
|
+ newXAxisColumn ? fields.xAxis = { column: { label: newXAxisColumn.label, type: newXAxisColumn.type } } : void(0);
|
|
|
+ newYAxisColumn ? fields.yAxis = { column: { label: newYAxisColumn.label, type: newYAxisColumn.type } } : void(0);
|
|
|
yield put({ type: 'silentSetField', name: 'pieConfig', value: deepAssign(pieConfig, { ...fields }) });
|
|
|
}else if(viewType === 'scatter') {
|
|
|
const { scatterConfig } = chartDesigner;
|
|
|
const { xAxis, yAxis, groupBy } = scatterConfig;
|
|
|
const newXAxisColumn = columns.find(c => c.name === xAxis.column.value);
|
|
|
const newYAxisColumn = columns.find(c => c.name === yAxis.column.value);
|
|
|
- const newGroupByColumn = columns.find(c => c.name === groupBy.key);
|
|
|
+ const newGroupByColumn = groupBy ? columns.find(c => c.name === groupBy.key) : null;
|
|
|
let fields = {};
|
|
|
- newXAxisColumn ? fields.xAxis = { column: { label: newXAxisColumn.label } } : void(0);
|
|
|
- newYAxisColumn ? fields.yAxis = { column: { label: newYAxisColumn.label } } : void(0);
|
|
|
- newGroupByColumn ? fields.groupBy = { label: newGroupByColumn.label } :void(0);
|
|
|
+ newXAxisColumn ? fields.xAxis = { column: { label: newXAxisColumn.label, type: newXAxisColumn.type } } : void(0);
|
|
|
+ newYAxisColumn ? fields.yAxis = { column: { label: newYAxisColumn.label, type: newYAxisColumn.type } } : void(0);
|
|
|
+ newGroupByColumn ? fields.groupBy = { label: newGroupByColumn.label, type: newGroupByColumn.type } :void(0);
|
|
|
yield put({ type: 'silentSetField', name: 'scatterConfig', value: deepAssign(scatterConfig, { ...fields }) });
|
|
|
}else if(viewType === 'dataView') {
|
|
|
const { dataViewConfig } = chartDesigner;
|
|
|
@@ -345,9 +345,9 @@ export default {
|
|
|
const newSortColumn = columns.find(c => c.name === sortColumn.key);
|
|
|
let arr = viewColumns.map(v => {
|
|
|
const newViewColumn = columns.find(c => c.name === v.name);
|
|
|
- return newViewColumn ? { label: newViewColumn.label } : {};
|
|
|
+ return newViewColumn ? { label: newViewColumn.label, type: newViewColumn.type } : {};
|
|
|
});
|
|
|
- newSortColumn ? fields.sortColumn = { label: newSortColumn.label } : void(0);
|
|
|
+ newSortColumn ? fields.sortColumn = { label: newSortColumn.label, type: newSortColumn.type } : void(0);
|
|
|
fields.viewColumns = arr;
|
|
|
yield put({ type: 'silentSetField', name: 'dataViewConfig', value: deepAssign(dataViewConfig, { ...fields }) });
|
|
|
}else if(viewType === 'aggregateTable') {
|
|
|
@@ -355,18 +355,18 @@ export default {
|
|
|
const { groupBy, targetColumn } = aggregateTableConfig;
|
|
|
let fields = {};
|
|
|
const newTargetColumn = columns.find(c => c.name === targetColumn.name);
|
|
|
- let arr = groupBy.map(g => {
|
|
|
+ let arr = groupBy ? groupBy.map(g => {
|
|
|
const newGroupByColumn = columns.find(c => c.name === g.key);
|
|
|
- return newGroupByColumn ? { label: newGroupByColumn.label } : {};
|
|
|
- });
|
|
|
- newTargetColumn ? fields.targetColumn = { label: newTargetColumn.label } : void(0);
|
|
|
+ return newGroupByColumn ? { label: newGroupByColumn.label, type: newGroupByColumn.type } : {};
|
|
|
+ }) : [];
|
|
|
+ newTargetColumn ? fields.targetColumn = { label: newTargetColumn.label, type: newTargetColumn.type } : void(0);
|
|
|
fields.groupBy = arr;
|
|
|
yield put({ type: 'silentSetField', name: 'aggregateTableConfig', value: deepAssign(aggregateTableConfig, { ...fields }) });
|
|
|
}
|
|
|
const { filters } = chartDesigner;
|
|
|
let fields = filters.map(f => {
|
|
|
const newFilterColumn = columns.find(c => c.name === f.name);
|
|
|
- return newFilterColumn ? { label: newFilterColumn.label } : {};
|
|
|
+ return newFilterColumn ? { label: newFilterColumn.label, type: newFilterColumn.type } : {};
|
|
|
});
|
|
|
yield put({ type: 'silentSetField', name: 'filters', value: deepAssign(filters, fields) });
|
|
|
}catch(e) {
|