|
|
@@ -1,6 +1,7 @@
|
|
|
import { message } from 'antd'
|
|
|
import * as service from '../services/index'
|
|
|
import URLS from '../constants/url'
|
|
|
+import STATISTICS_OPTION from '../components/chartDesigner/sections/statisticsOption.json'
|
|
|
|
|
|
export default {
|
|
|
namespace: 'chartDesigner',
|
|
|
@@ -280,6 +281,8 @@ export default {
|
|
|
yield put({ type: 'fetchScatterData' })
|
|
|
}else if(viewType === 'dataView') {
|
|
|
yield put({ type: 'fetchDataViewData' });
|
|
|
+ }else if(viewType === 'aggregateTable') {
|
|
|
+ yield put({ type: 'fetchAggregateTableData' });
|
|
|
}else {
|
|
|
console.log('nothing.......')
|
|
|
}
|
|
|
@@ -308,10 +311,19 @@ export default {
|
|
|
body: body
|
|
|
});
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
- res.viewType = 'bar';
|
|
|
- res.data.data.xTitle = barConfig.xAxis?`${barConfig.xAxis.column.label}${barConfig.xAxis.granularity.value?'('+barConfig.xAxis.granularity.label+')':''}`:null
|
|
|
- res.data.data.yTitle = barConfig.yAxis?`${barConfig.yAxis.column.label}${barConfig.yAxis.gauge.value?'('+barConfig.yAxis.gauge.label+')':''}`:null
|
|
|
- yield put({ type: 'silentSetField', name: 'chartOption', value: res });
|
|
|
+ let xTitle = barConfig.xAxis?`${barConfig.xAxis.column.label}${barConfig.xAxis.granularity.value?'('+barConfig.xAxis.granularity.label+')':''}`:null
|
|
|
+ let yTitle = barConfig.yAxis?`${barConfig.yAxis.column.label}${barConfig.yAxis.gauge.value?'('+barConfig.yAxis.gauge.label+')':''}`:null
|
|
|
+
|
|
|
+ let config = {
|
|
|
+ viewType: 'bar',
|
|
|
+ option: {
|
|
|
+ xAxis: res.data.data.xAxis,
|
|
|
+ serieses: res.data.data.serieses,
|
|
|
+ xTitle,
|
|
|
+ yTitle,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: config });
|
|
|
}else {
|
|
|
yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
}
|
|
|
@@ -343,9 +355,17 @@ export default {
|
|
|
});
|
|
|
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
- res.viewType = 'pie';
|
|
|
- res.data.data.columnName = pieConfig.xAxis.column.label + (pieConfig.xAxis.granularity.value ? '('+pieConfig.xAxis.granularity.label+')' : '');
|
|
|
- yield put({ type: 'silentSetField', name: 'chartOption', value: res });
|
|
|
+ let columnName = pieConfig.xAxis.column.label + (pieConfig.xAxis.granularity.value ? '('+pieConfig.xAxis.granularity.label+')' : '');
|
|
|
+
|
|
|
+ let config = {
|
|
|
+ viewType: 'pie',
|
|
|
+ option: {
|
|
|
+ xAxis: res.data.data.xAxis,
|
|
|
+ columnName: columnName,
|
|
|
+ serieses: res.data.data.serieses
|
|
|
+ }
|
|
|
+ }
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: config });
|
|
|
}else {
|
|
|
yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
}
|
|
|
@@ -375,10 +395,19 @@ export default {
|
|
|
body: body
|
|
|
});
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
- res.viewType = 'line';
|
|
|
- res.data.data.xTitle = lineConfig.xAxis?`${lineConfig.xAxis.column.label}${lineConfig.xAxis.granularity.value?'('+lineConfig.xAxis.granularity.label+')':''}`:null
|
|
|
- res.data.data.yTitle = lineConfig.yAxis?`${lineConfig.yAxis.column.label}${lineConfig.yAxis.gauge.value?'('+lineConfig.yAxis.gauge.label+')':''}`:null
|
|
|
- yield put({ type: 'silentSetField', name: 'chartOption', value: res });
|
|
|
+ let xTitle = lineConfig.xAxis?`${lineConfig.xAxis.column.label}${lineConfig.xAxis.granularity.value?'('+lineConfig.xAxis.granularity.label+')':''}`:null
|
|
|
+ let yTitle = lineConfig.yAxis?`${lineConfig.yAxis.column.label}${lineConfig.yAxis.gauge.value?'('+lineConfig.yAxis.gauge.label+')':''}`:null
|
|
|
+
|
|
|
+ let config = {
|
|
|
+ viewType: 'line',
|
|
|
+ option: {
|
|
|
+ viewType: 'line',
|
|
|
+ serieses: res.data.data.serieses,
|
|
|
+ xTitle,
|
|
|
+ yTitle
|
|
|
+ }
|
|
|
+ }
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: config });
|
|
|
}else {
|
|
|
yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
}
|
|
|
@@ -411,9 +440,18 @@ export default {
|
|
|
console.log(res);
|
|
|
if(!res.err && res.data.code > 0) {
|
|
|
res.viewType = 'scatter';
|
|
|
- res.data.data.xTitle = scatterConfig.xAxis?`${scatterConfig.xAxis.column.label}${scatterConfig.xAxis.granularity.value?'('+scatterConfig.xAxis.granularity.label+')':''}`:null
|
|
|
- res.data.data.yTitle = scatterConfig.yAxis?`${scatterConfig.yAxis.column.label}${scatterConfig.yAxis.gauge.value?'('+scatterConfig.yAxis.gauge.label+')':''}`:null
|
|
|
- yield put({ type: 'silentSetField', name: 'chartOption', value: res });
|
|
|
+ let xTitle = scatterConfig.xAxis?`${scatterConfig.xAxis.column.label}${scatterConfig.xAxis.granularity.value?'('+scatterConfig.xAxis.granularity.label+')':''}`:null
|
|
|
+ let yTitle = scatterConfig.yAxis?`${scatterConfig.yAxis.column.label}${scatterConfig.yAxis.gauge.value?'('+scatterConfig.yAxis.gauge.label+')':''}`:null
|
|
|
+
|
|
|
+ let config = {
|
|
|
+ viewType: 'scatter',
|
|
|
+ option: {
|
|
|
+ serieses: res.data.data.serieses,
|
|
|
+ xTitle,
|
|
|
+ yTitle,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: config });
|
|
|
}else {
|
|
|
yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
}
|
|
|
@@ -440,6 +478,63 @@ export default {
|
|
|
yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
}
|
|
|
},
|
|
|
+ *fetchAggregateTableData(action, { select, call, put }) {
|
|
|
+ try {
|
|
|
+ const chartDesigner = yield select(state => state.present.chartDesigner);
|
|
|
+ const { code, aggregateTableConfig, preparing } = chartDesigner;
|
|
|
+
|
|
|
+ const { targetColumn, statistics } = aggregateTableConfig;
|
|
|
+ const body = {
|
|
|
+ id: code,
|
|
|
+ columnName: "Y_",
|
|
|
+ operatorList: statistics,
|
|
|
+ groupByList: preparing.groupBy && preparing.groupBy.key ? [preparing.groupBy.key] : [],
|
|
|
+ };
|
|
|
+ let res = yield call(service.fetch, {
|
|
|
+ url: URLS.CHART_AGGREGATETABLE_OPTION,
|
|
|
+ body: body
|
|
|
+ });
|
|
|
+ console.log(body, res);return;
|
|
|
+ if(!res.err && res.data.code > 0) {
|
|
|
+ let c = chartDesigner.columns.filter(c => c.name === targetColumn)[0];
|
|
|
+ const resData = res.data.data;
|
|
|
+
|
|
|
+ let stypes = STATISTICS_OPTION.filter(o => statistics.indexOf(o.value) !== -1);
|
|
|
+
|
|
|
+ let columns = [{
|
|
|
+ title: '分析目标',
|
|
|
+ dataIndex: 'targetColumn'
|
|
|
+ }].concat(stypes.map(st => {
|
|
|
+ return {
|
|
|
+ title: st.label,
|
|
|
+ dataIndex: st.value
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ let data = {
|
|
|
+ targetColumn: c.label
|
|
|
+ }
|
|
|
+
|
|
|
+ let d = resData.valueList;
|
|
|
+ for(let k in d) {
|
|
|
+ data[k] = d[k]
|
|
|
+ }
|
|
|
+
|
|
|
+ let config = {
|
|
|
+ viewType: 'aggregateTable',
|
|
|
+ option: {
|
|
|
+ columns: columns,
|
|
|
+ data: [data]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: config });
|
|
|
+ }else {
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
+ }
|
|
|
+ }catch(e) {
|
|
|
+ console.error(e);
|
|
|
+ yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
subscriptions: {
|
|
|
setup({ dispatch, history }) {
|